CentOS6.5和RedHat6.5下以rpm方式安裝mysql-5.6.20


一、檢查下linux是不是已經安裝了MySQL

rpm -qa | grep -i mysql
#如果安裝了先卸載舊的版本 
yum -y remove mysql...

  

二、下載需要的安裝包,下載地址:

https://dev.mysql.com/downloads/mysql/5.6.html#downloads

三、開始逐個安裝

rpm -ivh MySQL-server-5.6.20-1.el6.x86_64.rpm
rpm -ivh MySQL-devel-5.6.20-1.el6.x86_64.rpm
rpm -ivh MySQL-client-5.6.20-1.el6.x86_64.rpm

四、修改配置文件位置並做相關設置

cp /usr/share/mysql/my-default.cnf /etc/my.cnf
vi /etc/my.cnf

  


#做如下配置

[client]
password = 123456
port = 3306
default-character-set=utf8
[mysqld]
port = 3306
character_set_server=utf8
character_set_client=utf8
collation-server=utf8_general_ci
#linux下mysql安裝完后是默認:表名區分大小寫,列名不區分大小寫; 0:區分大小寫,1:不區分大小寫
lower_case_table_names=1
#設置最大連接數,默認為 151,MySQL服務器允許的最大連接數16384
max_connections=1000
[mysql]
default-character-set = utf8

  

五、初始化MySQL及設置密碼

/usr/bin/mysql_install_db
service mysql start

  

六、登錄到mysql,第一次裝沒有密碼,直接回車

mysql -uroot -p
#設置root用戶的密碼
mysql> update user set password=password('123456') where user='root';

  

七、設置允許遠程登錄

mysql> use mysql;
mysql> select host,user,password from user;
mysql> update user set host='%' where user='root' and host='localhost';
mysql> flush privileges;
mysql> exit;

 

八、設置開機自啟動

chkconfig mysql on
chkconfig --list | grep mysql

  

九、MySQL的默認安裝位置說明

/var/lib/mysql/ #數據庫目錄
/usr/share/mysql #配置文件目錄
/usr/bin #相關命令目錄
/etc/init.d/mysql #啟動腳本 注:卸載mysql的時候,將這些目錄下的文件也刪掉。

  

A、可能遇到的錯誤(一)

2014-01-21 06:03:29 14964 [ERROR] InnoDB: auto-extending data file ./ibdata1 is of a different size 640 pages (rounded down to MB) than specified in the .cnf file: initial 768 pages, max 0 (relevant if non-zero) pages!
2014-01-21 06:03:29 14964 [ERROR] InnoDB: Could not open or create the system tablespace. If you tried to add new data files to the system tablespace, and it failed here, you should now edit innodb_data_file_path in my.cnf back to what it was, and remove the new ibdata files InnoDB created in this failed attempt. InnoDB only wrote those files full of zeros, but did not yet use them in any way. But be careful: do not remove old data files which contain your precious data!
2014-01-21 06:03:29 14964 [ERROR] Plugin 'InnoDB' init function returned error.
2014-01-21 06:03:29 14964 [ERROR] Plugin 'InnoDB' registration as a STORAGE ENGINE failed.
2014-01-21 06:03:29 14964 [ERROR] Unknown/unsupported storage engine: InnoDB
2014-01-21 06:03:29 14964 [ERROR] Aborting


在/var/lib/mysql/目錄下刪掉這三個文件:ibdata1 ib_logfile0 ib_logfile1 然后重啟mysql

cd /var/lib/mysql
rm ibdata1 ib_logfile0 ib_logfile1
service mysql start

  

B、可能遇到的錯誤(二)

[root@localhost local]# mysql -uroot -p
Enter password: 
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES)
方法操作很簡單,如下:
# /etc/init.d/mysql stop
# mysqld_safe --user=mysql --skip-grant-tables --skip-networking &
# mysql -u root mysql
//把空的用戶密碼都修改成非空的密碼。
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root' and host='root' or host='localhost';
mysql> FLUSH PRIVILEGES;
mysql> quit # /etc/init.d/mysqld restart
# mysql -uroot -p
Enter password: <輸入新設的密碼newpassword>

  

C、可能遇到的錯誤(三)

mysql> show databases;
ERROR 1820 (HY000): You must SET PASSWORD before executing this statement

這句話要求你重新設置一次密碼!

mysql> SET PASSWORD = PASSWORD('123456');
Query OK, 0 rows affected (0.03 sec)
mysql> create database roger;
Query OK, 1 row affected (0.00 sec)

轉自:http://blog.csdn.net/mw08091020/article/details/39234207


免責聲明!

本站轉載的文章為個人學習借鑒使用,本站對版權不負任何法律責任。如果侵犯了您的隱私權益,請聯系本站郵箱yoyou2525@163.com刪除。



 
粵ICP備18138465號   © 2018-2025 CODEPRJ.COM