CentOS Install MySQL

Source: Internet
Author: User
Tags file copy mysql client

CentOS Install MySQL

1. Download MySQL
After being acquired by Oracle, MySQL now exits the Enterprise and Community editions, the Community version is open source and the Enterprise Edition is charged.
The Community Edition can download the source code and also can download the binary package. Source installation is troublesome, there are many dependencies, if there is no special requirements can be directly downloaded binary package installation.
I am downloading the community version of MySQL Community Server, select the System option for Linux-generic 64-bit latest version 5.6.32


2. Unpacking the Package
Tar xzvf mysql-5.6.32-linux-glibc2.5-x86_64.tar.gz

3. Copying a directory
Copy the extracted MySQL directory to the local software directory of the system:
Execute command: Cp-r mysql-5.6.32-linux-glibc2.5-x86_64/usr/local/mysql

4. Add the system MySQL group and the MySQL User:
Execute command: Groupadd MySQL and Useradd-r-G mysql-s/bin/false MySQL

5. Install the database:
Go to install MySQL software directory: Execute command cd/usr/local/mysql
Modify current directory owner for MySQL User: Execute command chown-r mysql:mysql/usr/local/mysql
Initialize the database (after the 5.7.6 version executes the following command):
Bin/mysqld--initialize--user=mysql--datadir=/var/lib/mysql/data
Bin/mysql_ssl_rsa_setup
(The previous version of 5.7.6 executes the following command)
scripts/mysql_install_db--user=mysql

After execution, the default data file is placed under/var/lib/mysql
Modify the current directory owner as root User: Execute command chown-r root:mysql/usr/local/mysql
Modify the current data directory owner for MySQL User: Execute command chown-r mysql:mysql/var/lib/mysql/data
To this database installation is complete

6. Start the MySQL service and add the boot MySQL service:
Add Boot: Execute command CP Support-files/mysql.server/etc/init.d/mysql, put startup script into boot initialization directory
Start MySQL service: Execute command service MySQL start
Execute command: ps-ef|grep mysql see MySQL service description started successfully

7. Place the MySQL client in the default path:
Ln-s/usr/local/mysql/bin/mysql/usr/local/bin/mysql
Note: It is recommended to use the soft chain in the past, do not directly package file copy, easy to install multiple versions of MySQL system

8. Change the root user password of MySQL, 5.7 before the root initial password is empty, 5.7 after the default has a random password, and the password stored in the field has changed, the user table does not have password field:
5.7.6 Previous version Execution command:./bin/mysqladmin-u root password ' password '


9. Although it can be used at this time, but if you want remote graphics client access also need to set access permissions, 5.7 and the previous version is not the same, you need to be aware.
Login:
Mysql-uroot-p
Enter the MySQL system database:
Use MySQL;
To create a user:
CREATE USER ' testuser ' @ '% ' identified by ' password ';

Description: TestUser-The user name that you will create, host-Specifies which host the user can log on to, if localhost is available to local users, you can use the wildcard% if you want the user to be able to log on from any remote host. Password-The user's login password, the password can be empty, if it is empty, the user can not require a password to log on to the server.
Example: CREATE USER ' dog ' @ ' localhost ' identified by ' 123456 ';
CREATE USER ' pig ' @ ' 192.168.1.101_ ' idendified by ' 123456 ';
CREATE USER ' pig ' @ '% ' identified by ' 123456 ';
CREATE USER ' pig ' @ '% ' identified by ';
CREATE USER ' pig ' @ '% ';

Set permissions:
Command: GRANT privileges on databasename.tablename to ' username ' @ ' host '

Description: Privileges-user's operation permissions, such as SELECT, INSERT, UPDATE, etc. (see the last side of the article for a detailed list). Use all if you want to grant the permission. DatabaseName-database name, tablename-table name, if you want to grant the user the appropriate operation permissions on all databases and tables, the * representation, such as *. *.
Permissions include 14 permissions, such as Select,insert,update,delete,create,drop,index,alter,grant,references,reload,shutdown,process,file.
Example: GRANT SELECT, INSERT on Test.user to ' pig ' @ '% ';
GRANT all on * * to ' pig ' at '% ';

Note: A user authorized with the above command cannot authorize another user, and if you want the user to be authorized to do so, use the following command:
GRANT privileges on Databasename.tablename to ' username ' @ ' host ' with GRANT OPTION;

Modify the character set to Utf-8 to avoid writing to Chinese.


Next: Mobile MySQL data directory, to be continued

CentOS Install MySQL

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.