當前位置:首頁 » 編程軟體 » 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)

熱點內容
垃圾胡演算法 發布:2024-11-08 01:24:39 瀏覽:236
c語言裡面i 發布:2024-11-08 01:23:56 瀏覽:889
整理演算法 發布:2024-11-08 01:04:31 瀏覽:966
我的世界伺服器顯示檢測 發布:2024-11-08 00:50:48 瀏覽:444
miuirecovery編譯 發布:2024-11-08 00:47:07 瀏覽:172
雲空間卡密碼是什麼 發布:2024-11-08 00:40:02 瀏覽:951
海康sip伺服器地址怎麼填寫 發布:2024-11-08 00:32:13 瀏覽:395
安通加密 發布:2024-11-08 00:25:51 瀏覽:139
為什麼安卓和蘋果單核差距那麼大 發布:2024-11-08 00:25:50 瀏覽:439
存儲器的種類 發布:2024-11-08 00:14:10 瀏覽:189