1. Unzip the TAR-XVF MySQL package
tar-xvf Mysql-5.7.16-1.el6.x86_64.rpm-bundle.tar (can be found in MySQL website)
2. See if you need to uninstall
Installation time will be prompted with the installed RPM package conflict, so we first uninstall some RPM package, what to uninstall? We are going to uninstall some of the previously installed or system-brought packages that conflict with this installation
Execute command: Rpm-qa|grep MySQL to see what we want to uninstall which does not need to see:
Above, we will see that there are 5.1 of packages in the system, and we are installing 5.7 packages this time.
Now let's uninstall 5.1 packages.
3. Uninstall
Rpm-e mysql–xxxxxxxxxxx
such as: sudo rpm-e mysql-devel-5.1.66-2.el6_3.x86_64
4. Installation
Execute the command in turn:
sudo rpm-ivh--force mysql-community-common-5.7.16-1.el6.x86_64.rpm
sudo rpm-ivh--force mysql-community-libs-5.7.16-1.el6.x86_64.rpm
sudo rpm-ivh--force mysql-community-client-5.7.16-1.el6.x86_64.rpm
sudo rpm-ivh--force mysql-community-server-5.7.16-1.el6.x86_64.rpm
Note: Do it in turn, not in order, because there is a dependency between them.
# #Linux中很可能已经安装过老版本的mysql, so using the-UVH parameter, if there is no old version, then use-IVH
5. Start
The above installation is complete, below we start: sudo service mysqld start
Note: Get the root account's initial password in sudo vi/var/log/mysqld.log after startup
Start:
sudo service mysqld start
Stop it:
sudo service mysqld stop
Restart:
sudo service mysqld restart
6. Change the password
After logging in with the initial password, I find that no matter what SQL you output, there will be an error:
This prompts us to change the password, then we can change the password
mysql> alter user ' root ' @ ' localhost ' identified by ' newpassword ';
mysql> flush Privileges;
# #MySQL对用户密码安全性有所加强, so set the password must contain numbers, uppercase letters, lowercase letters, special symbols, if you set the password too simple, will prompt:
Let's look at the database code:
Mysql> Show variables like '%char% ';
If you need to modify the database encoding:
Edit/etc/my.conf
Increase in mysqld
Character_set_server=utf8
init_connect= ' SET NAMES UTF8 '
Save, and then restart Mysql:sudo service mysqld restart
The above MySQL installation is complete.
# #Linux下的MySQL基本管理操作
#在服务器上登录mysql
[Email protected] ~]# Mysql-hhost-uroot-ppassword
#修改密码
[[email protected] ~]# mysqladmin-u username-p Old password password new password
# # #以下是在mysql内部执行的操作
--View Users
Mysql> SELECT DISTINCT concat (' User: ', user, ' ' @ ', host, '; ') as usr from Mysql.user;
--Create a user, use% to represent any host, or use all to represent all permissions
Mysql> Grant Select on database. * to ' username ' @ ' login host ' identified by ' password ';
mysql> Update user Set Password=password ("Newpwd") where user= ' root ';//Change Password
mysql> flush Privileges; Refreshing the database
mysql> use dbname; Open Database
mysql> show databases; Show all databases
Mysql> Show tables; Displays all tables in the database MySQL: use MySQL first;
mysql> describe user; Displays column information for the user table in the MySQL database);
-OR
Mysql> CREATE USER ' root ' @ ' localhost ' identified by ' 123456 ';
Mysql> GRANT privileges on Databasename.tablename to ' username ' at ' host ';
mysql> SET PASSWORD for ' username ' @ ' host ' = PASSWORD (' NewPassword ');
--If the current user is logged in with set PASSWORD = PASSWORD ("NewPassword");
--Delete User
mysql> DROP USER ' username ' @ ' host ';
Install mysql-5.7.16 under Linux