MariaDB資料庫 分為原始碼版本和二進位版本,原始碼版本需要cmake編譯,這裡是二進位版本的安裝
# tar zxvf mariadb-5.5.31-linux-x86_64.tar.gz # mv mariadb-5.5.31-linux-x86_64 /usr/local/MySQL (必需這樣,很多指令碼或可執行程式都會直接存取這個目錄)# groupadd mysql 增加 mysql 屬組 # useradd -g mysql mysql 增加 mysql 使用者 並歸於mysql 屬組 # chown mysql:mysql -Rf /usr/local/mysql 設定 mysql 目錄的使用者及使用者組歸屬。 # chmod +x -Rf /usr/local/mysql 賜予可執行許可權 # cp /usr/local/mysql/support-files/my-medium.cnf /etc/my.cnf 複製預設mysql配置 檔案到/etc 目錄 # /usr/local/mysql/scripts/mysql_install_db --user=mysql 初始化資料 庫 # cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysql 複製mysql服務程式 到系統 目錄 # chkconfig mysql on 添加mysql 至系統服務並設定為開機啟動 # service mysql start 啟動mysql#vim /etc/profile 編輯profile,將mysql的可執行路徑加入系統PATHexport PATH=/usr/local/mysql/bin:$PATH #source /etc/profile 使PATH生效。#mysqladmin -u root password 'yourrootpassword' 設定root帳號及密碼#mysql -uroot -p 使用root使用者登入mysql[none]>use mysql 切換至mysql資料庫。[mysql]>select user,host,password from user; --查看系統許可權[mysql]>drop user ''@'localhost'; --刪除不安全的賬戶[mysql]>drop user root@'::1';[mysql]>drop user root@127.0.0.1;
[mysql]>select user,host,password from user; --再次查看系統許可權,確保不安全的賬戶均被刪除。
[mysql]>flush privileges; --重新整理許可權
1)修改字元集為UTF8
在[client]下面添加 default-character-set = utf8
在[mysqld]下面添加 character_set_server = utf8
修改完重啟:#service mysql restart
2)增加錯誤記錄檔
在[mysqld]下面添加:
log-error = /usr/local/mysql/log/error.loggeneral-log-file = /usr/local/mysql/log/mysql.log
修改完重啟:#service mysql restart
3) 設定為不區分大小寫,linux下預設會區分大小寫。
在[mysqld]下面添加:
修改完重啟:#service mysql restart
出現 FATAL ERROR: Could not find ./bin/my_print_defaults 解決方案
錯誤資訊:
FATALERROR:Couldnotfind./bin/my_print_defaultsIf you are using a binary release, you must run this script fromwithin the directory the archive extracted into. If you compiledMySQL yourself you must run 'make install' first.
或
[root@bogon scripts]# /usr/local/mysql/scripts/mysql_install_db --user=mysql&[1] 16874[root@bogon scripts]#FATAL ERROR: Could not find ./bin/my_print_defaultsIf you compiled from source, you need to run 'make install' tocopy the software into the correct location ready for operation.If you are using a binary release, you must either be at the toplevel of the extracted archive, or pass the --basedir optionpointing to that location.
解決方案:
[root@bogon scripts]# /usr/local/mysql/scripts/mysql_install_db --user=mysql --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data &(這點非常重要)
啟動mysql時報錯 mysqld_safe Logging to '/usr/local/mysql/data/zrf.err'.
以上所述是小編給大家介紹的Linux下安裝MariaDB資料庫問題及解決方案(二進位版本的安裝),希望對大家有所協助,如果大家有任何疑問請給我留言,小編會及時回複大家的。在此也非常感謝大家對雲棲社區網站的支援!
錯誤資訊:
[root@zrf ~]# /usr/local/mysql/bin/mysqld_safe --user=mysql&[1] 3527[root@zrf ~]# 101021 16:37:39 mysqld_safe Logging to '/usr/local/mysql/data/zrf.err'.101021 16:37:39 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data101021 16:37:39 mysqld_safe mysqld from pid file /usr/local/mysql/data/zrf.pid ended
解決辦法:
/usr/local/mysql/libexec/mysqld: Table 'mysql.plugin' doesn't exist
問題應該出在這裡!重新初始化下資料庫看下能否解決問題!
# /usr/local/mysql/bin/mysql_install_db --user=mysql
以上所述是小編給大家介紹的Linux下安裝MariaDB資料庫問題及解決方案(二進位版本的安裝),希望對大家有所協助,如果大家有任何疑問請給我留言,小編會及時回複大家的。在此也非常感謝大家對雲棲社區網站的支援!