mysql很好安裝吧,現(xiàn)在都用綠色版,打個(gè)對(duì)應(yīng)的mysql驅(qū)動(dòng)后啟動(dòng)服務(wù)就可以用了。可以用navicat或SqlDbx這些圖形界面可視軟件操作。
創(chuàng)新互聯(lián)建站專(zhuān)注為客戶提供全方位的互聯(lián)網(wǎng)綜合服務(wù),包含不限于成都網(wǎng)站建設(shè)、網(wǎng)站制作、溧陽(yáng)網(wǎng)絡(luò)推廣、微信小程序定制開(kāi)發(fā)、溧陽(yáng)網(wǎng)絡(luò)營(yíng)銷(xiāo)、溧陽(yáng)企業(yè)策劃、溧陽(yáng)品牌公關(guān)、搜索引擎seo、人物專(zhuān)訪、企業(yè)宣傳片、企業(yè)代運(yùn)營(yíng)等,從售前售中售后,我們都將竭誠(chéng)為您服務(wù),您的肯定,是我們最大的嘉獎(jiǎng);創(chuàng)新互聯(lián)建站為所有大學(xué)生創(chuàng)業(yè)者提供溧陽(yáng)建站搭建服務(wù),24小時(shí)服務(wù)熱線:18982081108,官方網(wǎng)址:www.cdcxhl.com
本人博客供參考
網(wǎng)頁(yè)鏈接
下載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?
啟動(dòng)MySQL服務(wù)?
shell systemctl start mysqld?
查看MySQL的啟動(dòng)狀態(tài)?
shell systemctl status mysqld?
開(kāi)機(jī)啟動(dòng)?
shell systemctl enable mysqld?
shell systemctl daemon-reload?
修改root本地登錄密碼?
mysql安裝完成之后,在/var/log/mysqld.log文件中給root生成了一個(gè)默認(rèn)密碼。通過(guò)下面的方式找到root默認(rèn)密碼,然后登錄mysql進(jìn)行修改:?
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默認(rèn)安裝了密碼安全檢查插件(validate_password),默認(rèn)密碼檢查策略要求密碼必須包含:大小寫(xiě)字母、數(shù)字和特殊符號(hào),并且長(zhǎng)度不能少于8位。否則會(huì)提示ERROR 1819 (HY000): Your password does not satisfy the current policy requirements錯(cuò)誤?
添加遠(yuǎn)程登錄用戶?
默認(rèn)只允許root帳戶在本地登錄,如果要在其它機(jī)器上連接mysql,必須修改root允許遠(yuǎn)程連接,或者添加一個(gè)允許遠(yuǎn)程連接的帳戶,為了安全起見(jiàn),我添加一個(gè)新的帳戶:?
mysql GRANT ALL PRIVILEGES ON?.?TO ‘yangxin’@’%’ IDENTIFIED BY ‘Yangxin0917!’ WITH GRANT OPTION;
以上部分個(gè)人實(shí)踐過(guò),以下內(nèi)容待實(shí)踐
數(shù)據(jù)庫(kù)存emoji 表情問(wèn)題
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有一個(gè)使用限制,mysql版本必須是5.5以上,大家需要注意,我目前用的ubuntu系統(tǒng)是16.04的。當(dāng)前mysql的字符集配置如上表,我們的目的是更改成utf8mb4。?
3.找到mysql的配置文件,可用命令?
sudo find / -name my.cnf?
我的配置文件位置如下,個(gè)別的位置有所不同?
/etc/mysql/mysql.conf.d/mysqld.cnf
4.修改配置文件?
在原文中添加以下內(nèi)容:?
[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’?
原文件中無(wú)“[client]”和“[mysql]”,需要手動(dòng)添加上。?
……
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服務(wù)?
sudo service mysql restart
6.查看結(jié)果?
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)
但是按照這篇博客安裝后使用terminal終端沒(méi)法鏈接mysql數(shù)據(jù)庫(kù),也就是沒(méi)法使用mysql -u root -p 命令(但是server已經(jīng)安裝成功),如果各位也遇到這種情況,可以安裝一個(gè)客戶端軟件workbench:
命令: sudo apt-get install mysql-workbench,安裝完成之后再u(mài)buntu里面搜索workbench,即可找到該客戶端軟件。
上傳?
傳到空間么?
你的空間在哪買(mǎi)的?還是你自己的本機(jī)?
如果是買(mǎi)的空間,應(yīng)該有Mysql服務(wù)器的,可能是你沒(méi)開(kāi)通
本機(jī)的話百度一下,去MYSQL的官網(wǎng)上下一個(gè)
那就開(kāi)通,在MYSQL管理那應(yīng)該有MYSQL地址的
然后安裝的時(shí)候把地址輸上就行了。
mysql
yum install mysql mysql-server mysql-devel
啟動(dòng)mysql服務(wù):/etc/init.d/mysqld start
設(shè)置mysql密碼:
直接使用”mysql”進(jìn)入數(shù)據(jù)庫(kù)模式,
mysql USE mysql;
mysql UPDATE user SET Password=PASSWORD(‘newpassword’) WHERE user=’root';
mysql FLUSH PRIVILEGES;
登陸
mysql -u root -p
Enter Password:
創(chuàng)建一個(gè)用戶管理數(shù)據(jù)庫(kù)
mysql create database demo
mysql GRANT ALL PRIVILEGES ON demo.* TO ‘guest’@’localhost’ IDENTIFIED BY ‘guest’ WITH GRANT OPTION;
mysql UPDATE user SET Password=PASSWORD(‘guest’) WHERE user=’guest';
設(shè)置MySQL字符集,vi /etc/my.cnf
#MySQL字符集
default-character-set = utf8
character_set_server = utf8
[client]
default-character-set=utf8
參考:PHP程序員,雷雪松的個(gè)人博客--
localhost為本機(jī)可訪問(wèn),%為所有機(jī)器可訪問(wèn)
參考文章:
CentOS7安裝MySQL8.0圖文教程_閏土的猹猹君的博客-CSDN博客_centos7安裝mysql8.0
Centos7離線安裝mysql8 - 大墨垂楊 - 博客園