当前位置:首页 » 编程软件 » centos7mysql启动脚本

centos7mysql启动脚本

发布时间: 2024-06-13 00:19:36

❶ centos7怎样安装mysql服务器

本人博客供参考

网页链接

下载mysql源安装包shell> wgethttp://dev.mysql.com/get/mysql57-community-release-el7-8.noarch.rpm
安装mysql源shell> yum localinstall mysql57-community-release-el7-8.noarch.rpm
检查mysql源是否安装成功
yum repolist enabled | grep “mysql.-community.”

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)

热点内容
linux编码命令 发布:2024-11-26 20:23:13 浏览:800
密码加密工具 发布:2024-11-26 20:23:06 浏览:691
如何破解加密的wifi 发布:2024-11-26 20:10:29 浏览:430
c脚本检查 发布:2024-11-26 19:56:34 浏览:393
服务器ip控制系统叫什么 发布:2024-11-26 19:56:31 浏览:746
ecshop文件夹权限 发布:2024-11-26 19:55:05 浏览:73
编程123 发布:2024-11-26 19:52:52 浏览:949
python数组排序排序算法 发布:2024-11-26 19:50:16 浏览:969
如保编程 发布:2024-11-26 19:29:58 浏览:812
我的世界手机版宝可梦生存多人服务器 发布:2024-11-26 19:29:52 浏览:730