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.初始化数据库
/usr/bin/mysql_install_db
6.启动mysql服务
service mysql start
7.设置密码
mysql -uroot –p
回车
SET PASSWORD = PASSWORD('123456');
8.允许远程登录
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.设置开机自启动
chkconfig mysql on
chkconfig --list | grep mysql
10.MySQL的默认安装位置
/var/lib/mysql/ #数据库目录
/usr/share/mysql #配置文件目录
/usr/bin #相关命令目录
/etc/init.d/mysql #启动脚本
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安装完后是默认:表名区分大小写,列名不区分大小写; 0:区分大小写,1:不区分大小写)
lower_case_table_names=1
#(设置最大连接数,默认为 151,MySQL服务器允许的最大连接数16384; )
max_connections=1000
[mysql]
default-character-set = utf8
11.查看字符集
show variables like '%collation%';
show variables like '%char%';