1、前期准备
(1)查看MySQL是否安装
rpm -qa|grep mysql
mysql-libs-5.1.73-7.el6.x86_64
(2)如果安装了MySQL,就先卸载
rpm -e --nodeps mysql-libs-5.1.73-7.el6.x86_64
(3)解压mysql-libs.zip文件到当前目录
cd /tmp
unzip mysql-libs.zip
cd mysql-libs
2、安装MySQL服务器
(1)安装MySQL服务端
rpm -ivh MySQL-server-5.6.24-1.el6.x86_64.rpm
(2)查看产生的随机密码
cat /root/.mysql_secret
CYgyeizHQxXoPR2N
(3)查看MySQL状态
service mysql status
(4)启动MySQL
service mysql start
3、安装MySQL客户端
(1)安装MySQL客户端
rpm -ivh MySQL-client-5.6.24-1.el6.x86_64.rpm
(2)登录MySQL
mysql -u root -pCYgyeizHQxXoPR2N
(3)修改密码
mysql>SET PASSWORD=PASSWORD('000000');
(4)退出MySQL
mysql>exit
4、MySQL主机配置(root在任何主机上都能登录MySQL)
(1)登录MySQL
mysql -uroot -p000000
(2)指定操作的数据库
mysql>use mysql;
(3)修改user表,把Host表内容修改为%
mysql>update user set host='%' where host='localhost';
(4)删除root用户的其他host
mysql>
delete from user where Host='hadoop102';
delete from user where Host='127.0.0.1';
delete from user where Host='::1';
(5)刷新权限
flush privileges;
5、修改字符集为utf8
(1)查看当前字符集默认设置
mysql> show variables like '%char%';
(2)修改配置文件(修改字符集为utf-8、忽略表名大小写、tab补全命令)
vi /etc/my.cnf
(4)重启mysql服务
[[email protected] ~]# service mysql stop
[[email protected] ~]# service mysql start
(3)查看当前字符集设置
[[email protected] ~]# mysql -u root -p000000
mysql> show variables like '%char%';
6、创建davinci配置信息保存的数据库
(1)创建davinci用的数据库
create database davinci3;
(2)查看数据库默认编码是否是utf8
show create database davinci3;
(3)退出
mysql>quit;