MySQL Green Extraction Version Installation and Configuration Operation Steps

  • 2021-10-25 08:06:50
  • OfStack

Operation steps:

1. Install the MySQL database

1. Download the MySQL-5. 6.17-winx64. zip file.

2. Extract to the specified directory, in this case D:\ mysql-5. 6.17-winx64.

3. Modify the configuration file. The name of my-default. ini is changed to my. ini. The parameter configuration in the file is as follows:


[mysqld]
    #  Settings mysql Installation directory of 
    basedir=D:/ mysql-5.6.17-winx64
    #  Settings mysql The directory where the data of the database is stored must be data
    datadir=D:/ mysql-5.6.17-winx64/data

Note: The path is a backslash, or it can be changed to two forward slashes, and it can be enclosed in double quotation marks.

Example:


 datadir="D:\ mysql-5.6.17-winx64\data"
    # mysql Port 
    port=3306
    #  Character set 
    character_set_server=utf8
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES

4. Install the MySQL service

Find cmd. exe under the path C:\ Windows\ System32, and right-click to run as administrator (strictly distinguish permissions under win 7, must be administrator)

Automatic: mysqld--install [service name]

Manual: mysqld--install--manual [service name]

mysqld -install MySQL --defaults-file="D:\ mysql-5.6.17-winx64\my.ini"

Note: Be sure to change "-defaults" to "-defaults". The mysqld instruction does not have the-d option, while MYSQL will treat-D as an option whenever it encounters xxxx-dxxxx when parsing parameters.

mysql looks for c by default:\ my. ini and c:\ windows\ my. ini, my. ini or my. cnf in the installation directory.

5. Start and stop of mysql service

Enter the bin directory of mysql under the doc command (D:\ mysql-5. 6.17-winx64\ bin > ),

Enter "net start mysql" to start mysql,

Enter "net stop mysql" to stop the mysql service.

2. root password modification and login

1. Log in

(Local) Log in to the mysql database. In the doc command window, enter the command: mysql-u root p

Enter and prompt for password.

Note: mysql decompressed version of the first installation administrator root password is empty, so directly enter once to log in to the mysql database.

Remote Login (Extended) Configuration


mysql -h 192.168.80.109 -u root  In fact, in fact, the p
   mysql -h 192.168.80.109 -u root -p123456

Note:

-h is the specified login ip,
-u specifies the user,
-p specifies the password. If you don't write anything after-p, you will be prompted to enter the password. After-p, you can also write the password directly, so you no longer need to enter the password.

2. Modify the root password

Start the mysql service and enter the command:

use mysql    

Enter using the mysql data source and the doc command box


update mysql.user set password=PASSWORD('newPassword') where User='root';

The doc command box is re-entered:

flush privileges;    

After mysql newly sets the user or changes the password, it is necessary to refresh the system permission related table of MySQL with flush privileges, otherwise access will be denied. Another method is to restart the mysql server to make the new setting take effect.

Precautions:

During this step, the following problems may occur:

ERROR 1044 (42000): Access denied for user ''@ 'localhost' to database 'mysql'.

Reason:

Because there is an anonymous account with an empty user name in the user table of the mysql database, although root is used when logging in, it is actually anonymous, which can be seen from the "'@' localhost" in the error prompt.

Solution:

Method 1:

1. Turn off mysql

# service mysqld stop  

2. Masking permissions


# mysqld_safe --skip-grant-table   

Screen appears: Starting demo from......

3. Open a new terminal input


# mysql -u root mysql                                                       
mysql> UPDATE user SET Password=PASSWORD('newpassword') where USER='root';  
 mysql> FLUSH PRIVILEGES;// Remember to use this sentence, otherwise if you shut down the previous terminal, the original error will appear again 
mysql> \q 

Method 2:

1. Turn off mysql

# service mysqld stop  

2. Masking permissions


# mysqld_safe --skip-grant-table   

Screen appears: Starting demo from......

3. Open a new terminal input


# mysql -u root mysql  
mysql> delete from user where USER='';  
mysql> FLUSH PRIVILEGES;// Remember to use this sentence, otherwise if you shut down the previous terminal, the original error will appear again   
mysql> \q  

3. Uninstall the installed MySQL

It can be viewed through the service manager of Windows. "Start"- > "Run", enter "services. msc" and enter. The service manager of Windows pops up, and then you can see the service item named "MySQL".

Enter D under the doc command:\ mysql-5. 6.17-winx64\ bin > Enter "mysqld-remove" or "sc delete mysql" to perform the uninstall service.

Summarize


Related articles: