How to Install LAMP(Apache, MySQL, PHP) Stack on Deepin

How to install MySQL Server 5.7 on Deepin


This Guide Will Introduce How to Install and Configure MySQL Server 5.7 on your Deepin Linux.

1. Update System

Open deepin terminal(ctrl+alt+T) and type these commands to update the deepin system. Enter user password if required.

$ sudo apt-get update && sudo apt-get upgrade



2.Install MySQL Server 5.7

Type following command to install MySQL server 5.7. (Enter y to continue installation)

$ sudo apt-get install mysql-server-5.7


3. Change User Authentication and Privileges

In Debian systems running MySQL 5.7 (and later versions) the root MySQL user is to
authenticate using the auth_socket plugin by default rather than with a password.
To connect MySQL as root, you have to switch its authentication method from auth_socket to mysql_native_password.

To do this, Open deepin terminal and enter the following commands.

Note:- Replace  'password'   with your password.

$ sudo mysql -u root

mysql> USE mysql;
mysql> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'password';
mysql> FLUSH PRIVILEGES;
mysql> exit;

$ sudo service mysql restart




4. Configure MySQL Server 5.7 (Optional)

Here you will be given a choice to set or change MySQL password for the root user, Validate password plugin, remove anonymous user accounts, disable root logins outside of localhost, and remove test databases.

Enter the following command to configure MySQL Server 5.7

$ mysql_secure_installation  

The result will look like this.

debuggerme@debuggerme-PC:~$ mysql_secure_installation

Securing the MySQL server deployment.

Enter password for user root: 

VALIDATE PASSWORD PLUGIN can be used to test passwords
and improve security. It checks the strength of password
and allows the users to set only those passwords which are
secure enough. Would you like to setup VALIDATE PASSWORD plugin?

Press y|Y for Yes, any other key for No: n
Using existing password for root.
Change the password for root ? ((Press y|Y for Yes, any other key for No) : n

 ... skipping.
By default, a MySQL installation has an anonymous user,
allowing anyone to log into MySQL without having to have
a user account created for them. This is intended only for
testing, and to make the installation go a bit smoother.
You should remove them before moving into a production
environment.

Remove anonymous users? (Press y|Y for Yes, any other key for No) : Y
Success.


Normally, root should only be allowed to connect from
'localhost'. This ensures that someone cannot guess at
the root password from the network.

Disallow root login remotely? (Press y|Y for Yes, any other key for No) : Y
Success.

By default, MySQL comes with a database named 'test' that
anyone can access. This is also intended only for testing,
and should be removed before moving into a production
environment.


Remove test database and access to it? (Press y|Y for Yes, any other key for No) : Y
 - Dropping test database...
Success.

 - Removing privileges on test database...
Success.

Reloading the privilege tables will ensure that all changes
made so far will take effect immediately.

Reload privilege tables now? (Press y|Y for Yes, any other key for No) : Y
Success.

All done! 


5. Test MySQL Server 

So you have successfully installed and configured MySQL Server 5.7. Now you can log in to MySQL Server and start coding.

$ mysql -h localhost -u root -p    # h - host , u - user , p - password