十年网站开发经验 + 多家企业客户 + 靠谱的建站团队
量身定制 + 运营维护+专业推广+无忧售后,网站问题一站解决
本人博客供参考
在巢湖等地区,都构建了全面的区域性战略布局,加强发展的系统性、市场前瞻性、产品创新能力,以专注、极致的服务理念,为客户提供成都网站建设、网站设计 网站设计制作按需策划设计,公司网站建设,企业网站建设,品牌网站设计,网络营销推广,外贸网站建设,巢湖网站建设费用合理。
网页链接
下载mysql源安装包shell wget
安装mysql源shell yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查mysql源是否安装成功
yum repolist enabled | grep “mysql.-community.”
安装MySQL
yum install mysql-community-server
启动MySQL服务
shell systemctl start mysqld
查看MySQL的启动状态
shell systemctl status mysqld
开机启动
shell systemctl enable mysqld
shell systemctl daemon-reload
修改root本地登录密码
mysql安装完成之后,在/var/log/mysqld.log文件中给root生成了一个默认密码。通过下面的方式找到root默认密码,然后登录mysql进行修改:
shell grep ‘temporary password’ /var/log/mysqld.log
shell mysql -uroot -p
mysql ALTER USER ‘root’@’localhost’ IDENTIFIED BY ‘MyNewPass4!’;
或者:
mysql set password for ‘root’@’localhost’=password(‘MyNewPass4!’);
注意:mysql5.7默认安装了密码安全检查插件(validate_password),默认密码检查策略要求密码必须包含:大小写字母、数字和特殊符号,并且长度不能少于8位。否则会提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements错误
添加远程登录用户
默认只允许root帐户在本地登录,如果要在其它机器上连接mysql,必须修改root允许远程连接,或者添加一个允许远程连接的帐户,为了安全起见,我添加一个新的帐户:
mysql GRANT ALL PRIVILEGES ON . TO ‘yangxin’@’%’ IDENTIFIED BY ‘Yangxin0917!’ WITH GRANT OPTION;
以上部分个人实践过,以下内容待实践
数据库存emoji 表情问题
mysql SHOW VARIABLES WHERE Variable_name LIKE ‘character_set_%’ OR Variable_name LIKE ‘collation%’;
+————————–+——————-+
| Variable_name | Value |
+————————–+——————-+
| character_set_client | utf8 |
| character_set_connection | utf8 |
| character_set_database | latin1 |
| character_set_filesystem | binary |
| character_set_results | utf8 |
| character_set_server | latin1 |
| character_set_system | utf8 |
| collation_connection | utf8_general_ci |
| collation_database | latin1_swedish_ci |
| collation_server | latin1_swedish_ci |
+————————–+——————-+
10 rows in set (0.02 sec)
可以看到我的mysql版本是5.7的,utf8mb4有一个使用限制,mysql版本必须是5.5以上,大家需要注意,我目前用的ubuntu系统是16.04的。当前mysql的字符集配置如上表,我们的目的是更改成utf8mb4。
3.找到mysql的配置文件,可用命令
sudo find / -name my.cnf
我的配置文件位置如下,个别的位置有所不同
/etc/mysql/mysql.conf.d/mysqld.cnf
4.修改配置文件
在原文中添加以下内容:
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld]
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect=’SET NAMES utf8mb4’
原文件中无“[client]”和“[mysql]”,需要手动添加上。
……
Here is entries for some specific programs
The following values assume you have at least 32M ram
[client]
default-character-set = utf8mb4
[mysql]
default-character-set = utf8mb4
[mysqld_safe]
socket = /var/run/mysqld/mysqld.sock
nice = 0
[mysqld]
#
* Basic Settings
#
user = mysql
pid-file = /var/run/mysqld/mysqld.pid
socket = /var/run/mysqld/mysqld.sock
port = 3306
basedir = /usr
datadir = /var/lib/mysql
tmpdir = /tmp
lc-messages-dir = /usr/share/mysql
skip-external-locking
character-set-client-handshake = FALSE
character-set-server = utf8mb4
collation-server = utf8mb4_unicode_ci
init_connect=’SET NAMES utf8mb4’
#
Instead of skip-networking the default is now to listen only on
……
5.重启mysql服务
sudo service mysql restart
6.查看结果
mysql SHOW VARIABLES WHERE Variable_name LIKE ‘character_set_%’ OR Variable_name LIKE ‘collation%’;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect…
Connection id: 3
Current database: * NONE *
+————————–+——————–+
| Variable_name | Value |
+————————–+——————–+
| character_set_client | utf8mb4 |
| character_set_connection | utf8mb4 |
| character_set_database | utf8mb4 |
| character_set_filesystem | binary |
| character_set_results | utf8mb4 |
| character_set_server | utf8mb4 |
| character_set_system | utf8 |
| collation_connection | utf8mb4_unicode_ci |
| collation_database | utf8mb4_unicode_ci |
| collation_server | utf8mb4_unicode_ci |
+————————–+——————–+
10 rows in set (0.00 sec)
1、查找以前是否装有mysql命令:rpm -qa|grep -i mysql
可以看到如下图的所示:
说明之前安装了:
MySQL-client-5.5.25a-1.rhel5
MySQL-server-5.5.25a-1.rhel5
2、停止mysql服务、删除之前安装的mysql
删除命令:rpm -e –nodeps 包名
# rpm -ev MySQL-client-5.5.25a-1.rhel5
# rpm -ev MySQL-server-5.5.25a-1.rhel5
3、查找之前老版本mysql的目录、并且删除老版本mysql的文件和库
find / -name mysql
查找结果如下:
[root@localhost ~]# find / -name mysql
/var/lib/mysql
/var/lib/mysql/mysql
/usr/lib64/mysql
删除对应的mysql目录
rm -rf /var/lib/mysql
rm -rf /var/lib/mysql
rm -rf /usr/lib64/mysql
具体的步骤如图:查找目录并删除
注意:卸载后/etc/my.cnf不会删除,需要进行手工删除
rm -rf /etc/my.cnf
4、再次查找机器是否安装mysql
rpm -qa|grep -i mysql
无结果,说明已经卸载彻底、接下来直接安装mysql即可
1.备份旧版mysql中的所有数据库 在cmd中进入旧版mysql安装目录下的bin目录。 我的目录(默认安装位置)是: C:\Program Files\MySQL\MySQL Server 5.5\bin ...
2.完全卸载旧版mysql 停止mysql服务 win+R→输入services.msc→服务→找到mysql并停止。 卸载mysql程序,mysql免安装版的删除安装目录即可 win+R→输入control→...