=================================================================
准备工作
1.关闭SELinux,防火墙,修改主机名
2.大概6个rpm的包
3.yum源要能连通
=================================================================
准备本地yum仓库
[root@node01 ~]# createrepo /mysql57/
[root@node01 ~]# cat /etc/yum.repos.d/aaa.repo
[aaa]
name=aaa
baseurl=ftp://172.16.8.100/centos7u2
enabled=1
gpgcheck=0
[mysql57]
name=mysql57
baseurl=file:///mysql57
enabled=1
gpgcheck=0
[root@node01 ~]# yum clean all
[root@node01 ~]# yum makecache
=================================================================
安装mysql
# yum install -y mysql-community-server
=================================================================
启动服务
[root@node01 ~]# systemctl start mysqld
[root@node01 ~]# systemctl enable mysqld
[root@node01 ~]# ss -antp | grep "mysqld"
=================================================================
获取root用户的临时密码
[root@node01 ~]# grep "password" /var/log/mysqld.log
=================================================================
登陆并修改root用户密码
[root@node01 ~]# mysql -u root -p
mysql> ALTER USER 'root'@'localhost' IDENTIFIED BY 'Tay123..';
mysql> FLUSH PRIVILEGES;
mysql> exit
(修改密码:方法2)
[root@node01 ~]# mysqladmin -u root -p password "Www.2.com"
Enter password:
===================================================================
修改编码
在Mac或Linux上,需要编辑MySQL的配置文件,把数据库默认的编码全部改为UTF-8。MySQL的配置文件默认存放在/etc/my.cnf或者/etc/mysql/my.cnf:
[client]
default-character-set = utf8
[mysqld]
default-storage-engine = INNODB
character-set-server = utf8
collation-server = utf8_general_ci
重启MySQL后,可以通过MySQL的客户端命令行检查编码:
$ mysql -u root -p
Enter password:
Welcome to the MySQL monitor...
...
mysql> show variables like '%char%';
+--------------------------+--------------------------------------------------------+
| Variable_name | Value |
+--------------------------+--------------------------------------------------------+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | utf8 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | utf8 |
| character_set_system | utf8 |
| character_sets_dir | /usr/local/mysql-5.1.65-osx10.6-x86_64/share/charsets/ |
+--------------------------+--------------------------------------------------------+
8 rows in set (0.00 sec)
看到utf8字样就表示编码设置正确。