NoesBlog Docs
搜索文档…
CentOS7 install MySQL5.7

处理其他DB

首先执行以下命令处理yum上的其他分发类型的数据库。
1
yum list installed mariadb\*
Copied!
1
yum list installed Percona\*
Copied!
执行以上命令若有显示,请执行以下命令。
1
yum-config-manager --disable mariadb
Copied!
1
yum-config-manager --disable percona-release
Copied!
卸载其他分发数据库
1
yum remove MariaDB-common MariaDB-compat MariaDB-server
Copied!
1
yum remove Percona-Server-client-55 Percona-Server-server-55 \
2
Percona-Server-shared-55.i686 percona-release
Copied!

安装mysql的yum源

访问以下链接获取到red hat的rpm文件地址,并使用wget命令下载到服务器上。
1
https://dev.mysql.com/downloads/repo/yum/
Copied!
也可以直接下载后使用ftp上传到服务器上。
安装yum源
1
yum localinstall mysql*****.noarch.rpm
Copied!
检查mysql源
1
yum repolist enabled | grep "mysql.*-community.*"
Copied!
安装mysql
1
yum install mysql-community-server
Copied!
启动mysql
1
systemctl start mysqld
Copied!
查看启动状态
1
systemctl status mysqld
Copied!
设置开机启动
1
systemctl enable mysqld
Copied!
1
systemctl daemon-reload
Copied!
查看生成的mysql root密码
1
grep 'temporary password' /var/log/mysqld.log
Copied!
[email protected]:后面的就是mysql密码,复制下来即可。
登陆mysql
1
mysql -u root -p
Copied!
粘贴密码。
设置root用户密码(请设置符合mysql57要求的高强度密码)
1
set password for [email protected] = password('your password!!');
Copied!
1
use mysql;
Copied!
设置root用户可远程连接
1
update user set host = '%' where user ='root';
Copied!
刷新用户权限
1
flush privileges;
Copied!
在mysql中执行以下命令设置数据库编码(直接复制所有命令然后回车确认一次即可)
1
set character_set_client = utf8;
2
3
set character_set_server = utf8;
4
5
set character_set_connection = utf8;
6
7
set character_set_database = utf8;
8
9
set character_set_results = utf8;
10
11
set collation_connection = utf8_general_ci;
12
13
set collation_database = utf8_general_ci;
14
15
set collation_server = utf8_general_ci;
Copied!
查看mysql编码
1
show variables like 'character%';
Copied!
显示如下内容代表成功
1
+--------------------------+----------------------------+
2
| Variable_name | Value |
3
+--------------------------+----------------------------+
4
| character_set_client | utf8 |
5
| character_set_connection | utf8 |
6
| character_set_database | utf8 |
7
| character_set_filesystem | binary |
8
| character_set_results | utf8 |
9
| character_set_server | utf8 |
10
| character_set_system | utf8 |
11
| character_sets_dir | /usr/share/mysql/charsets/ |
12
+--------------------------+----------------------------+
13
8 rows in set (0.01 sec)
Copied!
保存后重启MySQL服务
1
service mysqld.service restart
Copied!
添加防火墙端口
1
firewall-cmd --permanent --zone=public --add-port=3306/tcp
Copied!
重载防火墙配置
1
firewall-cmd --reload
Copied!
最近更新 3yr ago