centos7 mysql安装与用户设置
生活随笔
收集整理的這篇文章主要介紹了
centos7 mysql安装与用户设置
小編覺(jué)得挺不錯(cuò)的,現(xiàn)在分享給大家,幫大家做個(gè)參考.
1、環(huán)境:Centos 7.0 64位
2、mysql版本:5.7
3、安裝:https://dev.mysql.com/doc/refman/5.7/en/installing.html
3.1、創(chuàng)建mysql用戶和組:https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
3.2、忘記 linux下mysql5.7 root用戶的密碼:
service mysqld stop
修改/etc/my.inf 末尾添加 skip-grant-tables
service mysqld start
use mysql
update user set authentication_string=password('Kd8k&dfdl023') where user='root';
flush privileges;
將/etc/my.inf中的skip-grant-tables 刪掉;
service mysqld restart
mysql -uroot -p
use mysql
set password=password('newpassword');
3.3、創(chuàng)建mysql用戶
https://dev.mysql.com/doc/refman/5.7/en/adding-users.html
mysql> CREATE USER 'finley'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'trade'@'%' WITH GRANT OPTION;
3.5、查看mysql端口:
mysql> show variables like 'port';
3.4、打開(kāi)防火墻配置文件:
關(guān)閉并禁止firewall開(kāi)機(jī)啟動(dòng):
停止
systemctl stop firewalld.service
禁止開(kāi)機(jī)啟動(dòng)
systemctl disable firewalld.service
安裝iptables防火墻
yum install iptables-services
編輯防火墻配置文件打開(kāi)指定的端口號(hào)使用udp協(xié)議打開(kāi)52100端口:
vi /etc/sysconfig/iptables
保存退出
:wq
最后重啟防火墻使配置生效
systemctl restart iptables.service
設(shè)置防火墻開(kāi)機(jī)啟動(dòng)
systemctl enable iptables.service
3.5、查詢mysql配置文件
locate my.cnf
查看mysql默認(rèn)讀取的配置列表:
mysql --help|grep 'my.cnf'
查看3306端口信息:
netstat -apn|grep 3306
修改mysql設(shè)置中的bind-address選項(xiàng):
bind-address = 0.0.0.0
修改mysql設(shè)置中的port選項(xiàng):
port=3308
----->使用阿里云服務(wù)器,需額外配置阿里云安全規(guī)則,設(shè)置入場(chǎng)端口!!!!!(巨坑。。)
4、創(chuàng)建數(shù)據(jù)庫(kù)和數(shù)據(jù)表們:見(jiàn)sql文件。
5、centos設(shè)置cmd為支持中文
echo $LANG
yum group list
yum install system-config-users
yum groupinstall chinese-support
5.1、linux設(shè)置mysql編碼為utf-8
6、linux 命令執(zhí)行.sql文件
登錄mysql
執(zhí)行 source sqlpath
2、mysql版本:5.7
3、安裝:https://dev.mysql.com/doc/refman/5.7/en/installing.html
3.1、創(chuàng)建mysql用戶和組:https://dev.mysql.com/doc/refman/5.7/en/binary-installation.html
3.2、忘記 linux下mysql5.7 root用戶的密碼:
service mysqld stop
修改/etc/my.inf 末尾添加 skip-grant-tables
service mysqld start
use mysql
update user set authentication_string=password('Kd8k&dfdl023') where user='root';
flush privileges;
將/etc/my.inf中的skip-grant-tables 刪掉;
service mysqld restart
mysql -uroot -p
use mysql
set password=password('newpassword');
3.3、創(chuàng)建mysql用戶
https://dev.mysql.com/doc/refman/5.7/en/adding-users.html
mysql> CREATE USER 'finley'@'localhost' IDENTIFIED BY 'some_pass';
mysql> GRANT ALL PRIVILEGES ON *.* TO 'trade'@'%' WITH GRANT OPTION;
3.5、查看mysql端口:
mysql> show variables like 'port';
3.4、打開(kāi)防火墻配置文件:
關(guān)閉并禁止firewall開(kāi)機(jī)啟動(dòng):
停止
systemctl stop firewalld.service
禁止開(kāi)機(jī)啟動(dòng)
systemctl disable firewalld.service
安裝iptables防火墻
yum install iptables-services
編輯防火墻配置文件打開(kāi)指定的端口號(hào)使用udp協(xié)議打開(kāi)52100端口:
vi /etc/sysconfig/iptables
保存退出
:wq
最后重啟防火墻使配置生效
systemctl restart iptables.service
設(shè)置防火墻開(kāi)機(jī)啟動(dòng)
systemctl enable iptables.service
3.5、查詢mysql配置文件
locate my.cnf
查看mysql默認(rèn)讀取的配置列表:
mysql --help|grep 'my.cnf'
查看3306端口信息:
netstat -apn|grep 3306
修改mysql設(shè)置中的bind-address選項(xiàng):
bind-address = 0.0.0.0
修改mysql設(shè)置中的port選項(xiàng):
port=3308
----->使用阿里云服務(wù)器,需額外配置阿里云安全規(guī)則,設(shè)置入場(chǎng)端口!!!!!(巨坑。。)
4、創(chuàng)建數(shù)據(jù)庫(kù)和數(shù)據(jù)表們:見(jiàn)sql文件。
5、centos設(shè)置cmd為支持中文
echo $LANG
yum group list
yum install system-config-users
yum groupinstall chinese-support
5.1、linux設(shè)置mysql編碼為utf-8
6、linux 命令執(zhí)行.sql文件
登錄mysql
執(zhí)行 source sqlpath
轉(zhuǎn)載于:https://www.cnblogs.com/lindsay-chh/p/7089860.html
總結(jié)
以上是生活随笔為你收集整理的centos7 mysql安装与用户设置的全部?jī)?nèi)容,希望文章能夠幫你解決所遇到的問(wèn)題。
- 上一篇: Entity Framework入门教程
- 下一篇: 64位系统安装ODBC驱动的方法