Mysql5.6 install the full version under Centos

Before Installing

  • Installation on CentOS MySql official recommended way to install rpm-line installation.
  • But the way to use the online installation can not modify the installation path.
  • And the use of online installation, will lead the network is too slow, too much time spent
  • So: Let's be installed to extract the version of the way

1. jar package uploaded to the centos

It suggested that the mysql put under / usr / local, because the directory is decompressed version of the default directory. You can reduce a lot of configuration

1.1 into the / usr / local in

cd /usr/local

1.2-extracting archive into the / usr / local / mysql

tar zxvf 压缩包名 -C /usr/local/mysql

1.3 into the mysql folder

cd /usr/local/mysql

2. Create user groups and users

Root user is a super user, it is always to create users and groups, placing the highest authority user to operate.

2.1 add a user group named mysql

groupadd mysql

2.2 Creating user mysql, and specify the group for mysql

useradd -r  -g mysql mysql

3. empowerment, allowing users to groups and users have the operation right

Note that
the following command in there. This level represents the directory
must ensure that the current location is the folder / usr / local / mysql in

3.1 Change mysql user groups and users have permission to operate in the current folder

chown -R mysql:mysql ./

4. Initialize

The following commands need to ensure that in the / usr / local / mysql

4.1 /etc/my.cnf determine whether there is, if there is a deleted

ls /etc/my.cnf

4.2 If there is executed the following command, and if not, skip this step

rm /etc/my.cnf

4.3 initialize the database

./scripts/mysql_install_db --user=mysql

5. Modify Profile

My.cnf configuration and startup files, modify according to their needs. If no special operation, it can be directly copied.
The following commands are still needed to ensure that under the current folder in mysql

5.1 Copy the my.cnf file

cp support-files/my-default.cnf /etc/my.cnf

5.2 Copy boot files

cp support-files/mysql.server      /etc/rc.d/init.d/mysql

Start, restart, shut down mysql service

Start mysql service:

service mysql start

Close Services:

service mysql stop

Restart the service:

service mysql restart

Mysql must start in the state, it can change the password (the next step before they can do)

6. Operation mysql database

If the above configuration is performed correctly, can be imported directly into mysql mysql edit mode

mysql –u root –p

You will be prompted to enter a password
if no mysql command prompt, you need to add a soft link

ln -s /usr/local/mysql/bin/mysql /usr/bin/mysql

After entering to the mysql command, appears [mysql>]
CRUD operations to create the database according to their needs, create tables, etc.

7. Changing the root password

If the first installation of direct third step, if you forget the password to start from the first step.

  1. Enter /etc/my.cnf add skip-grant-tables to start in Safe Mode under [mysql]

    	vi /etc/my.cnf
    
  2. Restart the service:

       service mysql restart
    
  3. Log mysql, enter the password directly enter

    mysql -u root -p
    
  4. After entering to the mysql, mysql database to use

     use mysql
    
  5. change Password

      update user set password= passworD ("123456") where user='root';
    
  6. Refresh rights

     flush privileges;
    
  7. MySql exit edit mode

      exit
    

8. The user is provided with access to the

Enter the mysql command line

mysql -u root -p

Execute permissions given command

GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY '123456' WITH GRANT OPTION; 

Refresh rights

flush privileges;

drop out

quit
Published 84 original articles · won praise 50 · views 7017

Guess you like

Origin blog.csdn.net/qq_43115606/article/details/104000741