1. Download MySQL Community Server from the official website
2. Adding environment variables
path=%MYSQL_HOME%/bin
3. Copy my-default.ini file under the root directory and rename it my.ini. The configuration is as follows:
# For advice on how to change settings please see
# http://dev.mysql.com/doc/refman/5.6/en/server-configuration-defaults.html
# *** DO NOT EDIT THIS FILE. It's a template which will be copied to the
# *** default location during install, and will be replaced if you
# *** upgrade to a newer version of MySQL.
[mysqld]
# Remove leading # and set to the amount of RAM for the most important data
# cache in MySQL. Start at 70% of total RAM for dedicated server, else 10%.
# innodb_buffer_pool_size = 128M
# Remove leading # to turn on a very important data integrity option: logging
# changes to the binary log between backups.
# log_bin
# These are commonly set, remove the # and set as required.
basedir = D:\mysql
datadir = D:\mysql\data
# port = .....
# server_id = .....
# Remove leading # to set options mainly useful for reporting servers.
# The server defaults are faster for transactions and fast SELECTs.
# Adjust sizes as needed, experiment to find the optimal values.
# join_buffer_size = 128M
# sort_buffer_size = 2M
# read_rnd_buffer_size = 2M
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
4. Copy my-default.ini file under the root directory and rename it my.ini. The configuration is as follows:
Open cmd as an administrator and enter the / bin folder in the mysql root directory. Enter
mysqld -install
Input after successful installation
net start mysql
You can log in using mysql-u root-p
5. Find mysql service in the service and set up manual startup
6. Modify passwords
Method 1: Use SET PASSWORD command
First log in to MySQL.
Format: MySQL > set password for user name @localhost = password('new password');
Example: MySQL > set password for root@localhost = password ('123');
Method 2: mysqladmin was used.
Format: mysqladmin-u username-p old password new password
Example: mysqladmin -uroot -p123456 password 123
Method 3: Use UPDATE to edit user table directly
First log in to MySQL.
mysql> use mysql;
mysql> update user set password=password('123') where user='root' and host='localhost';
mysql> flush privileges;
Method 4: When you forget the root password, you can do this
Take windows as an example:
1. Close the running MySQL service.
2. Open the DOS window and go to the mysql bin directory.
3. Enter mysqld-skip-grant-tables to return. Skp-grant-tables means to skip permission table authentication when starting MySQL services.
4. Open another DOS window (because the DOS window just now can't move) and go to the mysql bin directory.
5. Enter Mysql to return. If successful, there will be a MySQL prompt >.
6. Connect permission database: use mysql;.
6. Change password: update user set password=password("123") where user="root"; (Don't forget to add a semicolon at the end).
7. Refresh permissions (required steps): flush privileges;.
8. Quit quit.
9. Log off the system and enter again. Log in with the username root and the new password 123 you just set.
7. Granting remote connection privileges
use mysql
select host, user from user;
update user set host='%' where user='root';
//ERROR 1062 (23000): Duplicate entry'%-root'for key'PRIMARY' is ignored
flush privileges;
Restart service, local host password becomes empty, you can use local ip + original password link
This time, the configuration of the new computer is not as strange as it used to be.