MySQL common commands (import, export, create services, create users, change passwords, etc.)

1. Install the service
  • mysqld install service name

2. Uninstall the service
  • mysqld --remove mysql (service name)

3. Start the mysql service
  • net start mysql

4. Login to mysql
  • mysql -u root -p

5. Reset password:
  • Method 1: Use the SET PASSWORD command
  • First log in to MySQL.
  • Format: mysql> set password for username@localhost = password('new password');
  • 例子:mysql> set password for root@localhost = password('123');

  • Method 2: Using mysqladmin
  • Format: mysqladmin -u username -p old password password new password
  • Example: mysqladmin -uroot -p123456 password 123

  • Method 3: Edit the user table directly with UPDATE
  • First log in to MySQL.
  • mysql> use mysql;
  • mysql> update user set password=password('123') where user='root' and host='localhost';
  • mysql> flush privileges;

6. The command for mysql to export the database:
  • mysqldump -u root -p test > c:/test.sql


7. Import database command:
  • mysql>source d:\test.sql

8. The command to query the dataset:
  • 1)show variables like 'character_set_%'
  • 2)show variables like 'coll%'

9. The command to create the database:
  • CREATE DATABASE test
  • CHARACTER SET 'utf8'
  • COLLATE 'utf8_general_ci';

10. Modify the table column name
  • alter table generalscore change  column srid pid ;

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=326490563&siteId=291194637