I. Install MySQL database under CentOS7
CentOS7 The default installation package does not already have a Mysql-server installation package, and there is no remote mirror. The default is MARIADB (a branch of MySQL, one of the reasons for developing this branch is that Oracle has acquired the potential risk of MySQL closing the source after acquiring MySQL, so the community uses a branching approach to avoid this risk by referring to Baidu. Development is similar).
Reference article:CentOS7 installing MySQL
http://www.centoscn.com/mysql/2016/0315/6844.html
Here is the main installation of MySQL version of
First, the preparation before installation:
1. Check if it is installed
# Yum List Installed | grep MySQL
If any, uninstall it all
# yum -y remove mysql-libs. x86_64
Download MySQL Yum Repository Address: http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
# wget http://dev.mysql.com/get/mysql-community-release-el7-5.noarch.rpm
If prompted -bash: wget: 未找到命令
, first perform the yum install wget
installation wget
Add MySQL Yum Repository to your system Repository list and execute:
# yum localinstall-y mysql-community-release-el7-5. Noarch. RPM
2. Verify that the installation is successful
# Yum Repolist enabled | grep "mysql.*-community.*"
MySQL 5.6 Community server, etc.
Second, install MySQL through Yum
# yum Install-y mysql-community-server
Execution completion will prompt "complete!" ”。 At this point, MySQL installation is complete, it contains Mysql-community-server, Mysql-community-client, Mysql-community-common, mysql-community-libs four packages
RPM -qi mysql-community-server. x86_64 0: 5. 6. 24-3. El7
Verify the installation is successful:Whereis MySQL can see several directories
third, start and close MySQL Server
# systemctl start mysqld
Start MySQL # systemctl start mysqld
View MySQL status # systemctl status mysqld
stop MySQL # systemctl stop mysqld
To test whether MySQL is successful:
Mysql
Access to MySQL command line interface
Mysql>
is successful, local access is available.
Iv. Related Configurations
1. Firewall, open port
To access MySQL remotely, you need to open the default port number 3306.
Using Firewall-cmd (recommended)
Firewall-cmd --permanent--zone=public--add-port=3306/tcp
Firewall-cmd --permanent--zone=public--add-port=3306/udp
Or use other methods to develop ports (iptables, etc.)
2. Settings such as account password
After the server starts, you can perform
Mysql_secure_installation;
Enter the root original password (the initial installation is empty), next, for security, MySQL will prompt you to reset the root password, remove other user accounts, disable root telnet, remove the test database, reload the privilege form, etc., you just enter Y to continue execution Can
3. Remote Access settings
A. Creating an Administrator account
Create an Admin user admin account, password is Some_pass
CREATE USER ' admin ' @'% ' identified by ' Some_pass ';
Grant all remote access permissions to this user. This user is mainly used to manage the entire database, backup, restore and other operations.
Flush privileges; Make authorization effective immediately
B. Create a regular user and authorize
Example (log in with root): (123456 is the password can be changed,% for any IP can be accessed, if replaced by the specified IP only allow the specified IP server access)
mysql > Use MySQL;
MySQL > Grant all privileges on * * to ' root ' @ '% ' identified by ' 123456 ';
MySQL > Flushn privileges;
4.开机启动
查看MySQL服务是否开机启动
# systemctl is-enabled mysql.service;echo $?enabled0
If it is enabled then the boot is automatic, if not, perform
chkconfig --levels 235 mysqld on
5. Setting the character set
SHOW VARIABLES like ' character% ';
You can see that the default server character indicator is latin1 and unfriendly to Chinese.
modifying /etc/my.cnf
files, adding settings for character sets
[mysqld] character_set_server = utf8[mysql]default-character-set = utf8
6.其他问题
1045(28000)错误 用户登陆信息错误,在user表中找不到
可以进入 mysql 命令行界面 查找mysql数据库 usre表 user,host,password看password是否正确,删掉use用户位null或者空字符串的那一行。
flush privileges; //重启下权限
再尝试连接MySQL数据库。
CentOS7 install MySQL and configure the remote connection