Most of the mysql installation tutorials on the web are mostly for the older versions and are not suitable for the newer versions of mysql
Here are the installation steps for the new version. I am using mysql 8.0.18-Winx64
The first step
Added the MySQL configuration file
Open the folder C:\web\mysql-8.0.11, create the configuration file my.ini in this folder, edit the my.ini file to configure the following basic information:
[mysqld] # set default character set=utf8 [mysqld] # set port = 3306 # set installation directory of mysql Basedir =C:\\web\\mysql-8.0.11 # # datadir=C:\\web\\sqldata # Max_connections =20 # Default storage engine for creating new tables =INNODBCopy the code
The second step
Start MySQL database:
Open the CMD command line tool as an administrator and switch to the following directory:
CD C: \ web \ mysql - 8.0.11 \ binCopy the code
Initialize the database:
mysqld --initialize --console
Copy the code
Enter the following installation command:
mysqld install
Copy the code
Start by running the following command:
net start mysql
Copy the code
The third step
Set skip permission authentication:
Mysql > disable mysql service;
net stop mysql
Copy the code
Then enter the following instructions to skip permissions
mysqld --console --skip-grant-tables --shared-memory
Copy the code
[img- twrmfvic-1573695374846] [img- twrmfvic-1573695374846] [img- twrmfvic-1573695374846] [img- twrmfvic-1573695374846] [img- twrmfvic-1572491945325.png]
Then reopen a new command window
No-password login:
mysql -u root -p
Copy the code
[img- k2XB6jcq-1573695374847] [img- k2XB6jcQ-1573695374847] [img- k2XB6jcQ-1573695374847] [img- k2XB6jcQ-1573695374847] [img- K2XB6jcQ-1573695374847] [img- K2XB6jcQ-1573695374847]
The fourth step
A new user
Connecting to the database
use mysql
Copy the code
A new user
create user 'test' @'localhost' identified by '123456';
Copy the code
Error message:
ERROR 1290 (HY000): The MySQL server is running with the --skip-grant-tables option so it cannot execute this statement
Copy the code
Solution: Refresh the permission
flush privileges
Copy the code
And then retype
create user 'test' @'localhost' identified by '123456';
Copy the code
[Img – oa5dbcGG-1573695374847] [img- oa5dbcgg-1573695374847] [img- oa5dbcgg-1573695374847] [img- oa5dbcGG-1573695374847] [img- oa5dbCGG-1572494065254.png]
Remember to add permissions to new users
grant reload on *.* to 'test'@'localhost' ;
Copy the code
grant all privileges on *.* to test@localhost ;
Copy the code
If you don’t want to create a new user and just want to change the password of the existing database, enter the following command:
Update db name set authentication_string=("123456") WHERE user="root";Copy the code
[img- c2UYaylx-1573695374848] [img- c2uyaylx-1573695374848] [img- c2uyaylx-1573695374848] [img- c2uyaylx-1573695374848] [img- c2uyaylx-1573695374848] [img- c2uyaylx-1573695374848]
And then refresh the permissions
flush privileges
Copy the code
Exit the command window and restart the mysql service
Matters needing attention
The first time you link to a database using the IntelliJ IDE:
Server returns invalid timezone. Go to 'Advanced' tab and set 'serverTimezon
Cause: The time zone is incorrect. The default time zone is UTC, which is 8 hours later than Beijing time. So change the duration of mysql
Mysql > open mysql > open mysql > open mysql > open mysql > open mysql > open
set global time_zone='+8:00';
Copy the code
Reconnect successfully