使用yum安裝,具體過程參見最下邊的參考文章。html
安裝以後啓動失敗:mysql
[root@localhost ~]# service mysqld start Starting mysqld: [ FAILD ]
啓動失敗,查看出錯緣由(記錄在/var/log/mysqld.log 文件裏):sql
[root@localhost ~]# cat /var/log/mysqld.log 190425 13:56:00 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql /usr/libexec/mysqld: Table 'mysql.plugin' doesn't exist 190425 13:56:00 [ERROR] Can't open the mysql.plugin table. Please run mysql_upgrade to create it. 190425 13:56:00 InnoDB: Initializing buffer pool, size = 8.0M 190425 13:56:00 InnoDB: Completed initialization of buffer pool InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes InnoDB: than specified in the .cnf file 0 5242880 bytes! 190425 13:56:00 [ERROR] Plugin 'InnoDB' init function returned error. 190425 13:56:00 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 190425 13:56:00 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist 190425 13:56:00 mysqld_safe mysqld from pid file /var/run/mysqld/mysqld.pid ended 190425 13:58:07 mysqld_safe Starting mysqld daemon with databases from /var/lib/mysql 190425 13:58:07 InnoDB: Initializing buffer pool, size = 8.0M 190425 13:58:07 InnoDB: Completed initialization of buffer pool InnoDB: Error: log file ./ib_logfile0 is of different size 0 50331648 bytes InnoDB: than specified in the .cnf file 0 5242880 bytes! 190425 13:58:07 [ERROR] Plugin 'InnoDB' init function returned error. 190425 13:58:07 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed. 190425 13:58:07 [Note] Event Scheduler: Loaded 0 events 190425 13:58:07 [Note] /usr/libexec/mysqld: ready for connections. Version: '5.1.73' socket: '/var/lib/mysql/mysql.sock' port: 3306 Source distribution # 注意!(這裏的提示是解決以後的,剛安裝完mysql時啓動是報錯的,OK那裏是FAILD) # 這裏的提示最後幾行是解決以後啓動了軟件而後端口開放了。與前邊報錯顯示在同一文件裏了。)
mysql報錯 [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't exist數據庫
mysql_install_db
(參考自文章2。)後端
# mysql默認不推薦用root用戶來啓動軟件。正常狀況下用root啓動會有提示或報錯,這裏沒有報錯就啓動了。須要注意一下。 [root@localhost ~]# service mysqld start Starting mysqld: [ OK ]
CREATE USER 'root'@'localhost' IDENTIFIED BY '[這裏替換成想要設置的密碼]'; GRANT SELECT,INSERT,UPDATE,DELETE ON *.* TO 'root'@'localhost'; GRANT ALL ON *.* TO 'root'@'localhost';
# 說明:mysql對用戶訪問的控制比較完善,同一個用戶名從不一樣的機器訪問同一數據庫權限也是不一樣的。 # 以root爲例。同一個用戶root對應mysql數據庫中user表裏的多行數據。從本地訪問時user表裏對應host爲localhost的一行。 # 即便user表裏有一行的host叫作localhost.localdomain也不能從本地訪問。(經驗如此,具體緣由不詳) # 從遠程訪問時須要配置user表裏對應host爲%的一行。 Enter password: ******* select user,host from user; update user set host='%' where user='root'; flush privileges;
一、Linux學習之CentOS(十三)--CentOS6.4下Mysql數據庫的安裝與配置dom
二、mysql報錯Fatal error: Can't open and lock privilege tables: Table 'mysql.host' doesn't existsocket