MySQL8.0 Installation

Source: Internet
Author: User
Tags log log

Create a user group for MySQL

[[email protected] ~]# Groupadd MySQL

Add MySQL User

[[email protected] ~]# useradd-r-g MySQL MySQL

Create a Directory
[Email protected] ~]# mkdir-p/kingsql/database/mysql/tmp/
[Email protected] ~]# mkdir-p/kingsql/database/mysql/log/

Create a Mysqld.log log
[Email protected] ~]# Touch/kingsql/database/mysql/log/mysqld.log

Move the installation package to the MySQL directory
[Email protected] ~]# MV mysql8.0_kingsql.tar.gz/kingsql/database/mysql/
[Email protected] ~]# cd/kingsql/database/mysql/

Modify the user who owns the directory
[Email protected] ~]# chown mysql:mysql-r/kingsql

Unpacking the installation package
[Email protected] mysql]# TAR-ZXVF mysql8.0_kingsql.tar.gz
bin/
Bin/mysqlxtest
Bin/mysql_tzinfo_to_sql

..............................

Executes the installation instructions, and an initial password is given at the end of the installation.

[Email protected] mysql]#/kingsql/database/mysql/bin/mysqld--initialize--user=mysql--datadir=/kingsql/database/ Mysql/data--basedir=/kingsql/database/mysql

Modify MY.CNF to add the following:
[Email protected] etc]# VI/ETC/MY.CNF
[Client]
Socket =/kingsql/database/mysql/tmp/mysql.sock


[Mysqld_safe]
Log-error=/kingsql/database/mysql/log/mysqld.log
Pid-file=/kingsql/database/mysql/mysqld.pid


[Mysqld]
Basedir =/kingsql/database/mysql
DataDir =/kingsql/database/mysql/data
Port = 3306
Socket =/kingsql/database/mysql/tmp/mysql.sock
Sql_mode=no_engine_substitution,strict_trans_tables

Write environment variable modifications to/etc/profile

[Email protected] etc]# echo "Export path= $PATH:/kingsql/database/mysql/bin" >>/etc/profile

Refresh/etc/profile
[Email protected] etc]# Source/etc/profile

Mysqld_safe script starts MySQL server and continues to monitor its running status

[Email protected] ~]# mysqld_safe&
[1] 2989
[Email protected] ~]# 2018-02-05t05:24:40.919162z mysqld_safe Logging to '/kingsql/database/mysql/log/mysqld.log '.
2018-02-05t05:24:40.948708z Mysqld_safe starting mysqld daemon with databases From/kingsql/database/mysql/data

# Get temporary password grep ' temporary password '/var/log/mysqld.log

# Sign in mysql-u with temporary password root-p

Log in to MySQL, password is just the initial password

[Email protected] ~]# mysql-u root-p
Enter Password:

# Change the password of the root account
mysql> alter user ' root ' @ ' localhost ' identified by ' Oracle ';
Query OK, 0 rows affected (0.16 sec)

Using the MySQL Database

mysql> use MySQL
Reading table information for completion of table and column names
Can turn off this feature to get a quicker startup with-a

Database changed

The default account's host property is localhost, meaning that the account can only be used locally, if you want to use an account to log in remotely, you must change the account's Host property value to%.
mysql> Update user set host= '% ';
Query OK, 4 rows affected (0.11 sec)
Rows Matched:4 Changed:4 warnings:0

Refresh Permissions

mysql> flush Privileges;

Query OK, 0 rows affected (0.02 sec)

Mysql>
Mysql> GRANT All on * * to ' root ' @ '% '; # * * represents all fields for all tables
Query OK, 0 rows affected (0.11 sec)

mysql> flush Privileges;

Query OK, 0 rows affected (0.03 sec)

Mysql>

Change Password authentication method to Mysql_native_password
mysql> ALTER USER Root identified with Mysql_native_password by ' Oracle ';

Query OK, 0 rows affected (0.11 sec)

Mysql>

Refresh Permissions
mysql> flush Privileges;

Query OK, 0 rows affected (0.02 sec)

MySQL8.0 Installation

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.