1.卸載之前的mysql
列出所有被安裝的mysql
rpm package **rpm -qa | grep mariadb
卸載
rpm -e --nodeps mariadb-libs-5.5.37-1.el7_0.x86_64
2.在/etc/下面新建my.cnf
3.分別安裝server devel client
rpm -ivh MySQL-server-advanced-5.6.22-1.el7.x86_64.rpm
rpm -ivh MySQL-devel-advanced-5.6.22-1.el7.x86_64.rpm
rpm -ivh MySQL-client-advanced-5.6.22-1.el7.x86_64.rpm
下載地址:mysql.zip
密碼:u12s
4.安裝perl
yum install -y perl-Module-Install.noarch
5.初始化數(shù)據(jù)庫
/usr/bin/mysql_install_db
6.啟動(dòng)mysql服務(wù)
service mysql start
7.設(shè)置密碼
mysql -uroot –p
回車
SET PASSWORD = PASSWORD('123456');
8.允許遠(yuǎn)程登錄
mysql> use mysql;
mysql> select host,user,password from user;
+-----------------------+------+-------------------------------------------+
| host | user | password |
+-----------------------+------+-------------------------------------------+
| localhost | root | *6BB4837EB74329105EE4568DDA7DC67ED2CA2AD9 |
| localhost.localdomain | root | *1237E2CE819C427B0D8174456DD83C47480D37E8 |
| 127.0.0.1 | root | *1237E2CE819C427B0D8174456DD83C47480D37E8 |
| ::1 | root | *1237E2CE819C427B0D8174456DD83C47480D37E8 |
+-----------------------+------+-------------------------------------------+
mysql> update user set password=password('123456') where user='root';
mysql> update user set host='%' where user='root' and host='localhost';
mysql> flush privileges;
mysql> exit
9.設(shè)置開機(jī)自啟動(dòng)
chkconfig mysql on
chkconfig --list | grep mysql
10.MySQL的默認(rèn)安裝位置
/var/lib/mysql/ #數(shù)據(jù)庫目錄
/usr/share/mysql #配置文件目錄
/usr/bin #相關(guān)命令目錄
/etc/init.d/mysql #啟動(dòng)腳本
10.修改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安裝完后是默認(rèn):表名區(qū)分大小寫,列名不區(qū)分大小寫; 0:區(qū)分大小寫咒林,1:不區(qū)分大小寫)
lower_case_table_names=1
#(設(shè)置最大連接數(shù)氧枣,默認(rèn)為 151,MySQL服務(wù)器允許的最大連接數(shù)16384; )
max_connections=1000
[mysql]
default-character-set = utf8
11.查看字符集
show variables like '%collation%';
show variables like '%char%';