Restart mysql database command

How to restart MySQL and start MySQL correctly

Methods for restarting mysql on linux platforms and windows platforms

The correct way to restart MySQL under Linux:

1, MySQL installed from rpm package

servicemysqldrestart

2, MySQL installed from source package

//linux command to shut down MySQL

$mysql_dir/bin/mysqladmin-uroot-pshutdown

//linux startup MySQL commands

$mysql_dir/bin/mysqld_safe&

Where mysql_dir is the MySQL installation directory, and mysqladmin and mysqld_safe are located in the bin directory of the MySQL installation directory, which is easy to find.

3. When all the above methods are invalid, you can shut down MySQL by forcing the command: “killallmysql”, but it is not recommended to use this way, because this barbaric method will forcibly terminate the MySQL database service, which may lead to table corruption

Steps or method:RedHatLinux(FedoraCore/CentOS)

1. Start:/etc/init.d/mysqldstart

2. Stop:/etc/init.d/mysqldstop

3. Restart:/etc/init.d/ mysqldrestart

Debian/UbuntuLinux

1. start: /etc/init.d/mysqlstart

2. stop: /etc/init.d/mysqlstop

3. restart: /etc/init.d/ mysqlrestart

Windows

1. Click “Start” -> “Run” (shortcut key Win+R).

2. Start: enter netstopmysql

3. Stop: enter netstartmysql

Hint* RedhatLinux also supports servicecommand, start: #servicemysqldstart stop: #servicemysqldstop servicemysqldstoprestart:#servicemysqldrestart

*Windows can’t restart directly, you can only stop and then start.

MySQL start, stop, restart methods:

I. Starting methods

1. Use service to start: servicemysqldstart

2. Use mysqld script to start: /etc/int.d/mysqldstart

3, Use safe_mysqld to start: safe_mysqld&

2. Stop

1. Use service to start: servicemysqldstop

2. Use mysqld script to start: /etc/inint.d/mysqldstop

3. mysqladminshutdown

Three: Restart

1. Use service to start: servicemysqldrestart

2. Use mysqld script to start: /etc/inint.d/mysqldrestart

How to restart MySQL and start MySQL correctly

Tags: ora steps database redwindows platform startbodyinux start

What are the linux commands to query mysql

What are the linux commands to query mysql:

1, the command to start mysql: mysqladminstart

/ect/init.d/mysqlstart (preceded by the installation path of mysql)

2, the command to restart mysql: mysqladminrestart

/ect/init.d/mysqlrestart (preceded by the installation path of mysql)

2 The command to restart mysql: mysqladminrestart

/ect/init.d/mysqlrestart (preceded by mysql’s installation path)

3. The command to shut down mysql: mysqladminshutdown

/ect/init. d/mysqlshutdown(preceded by the installation path of mysql)

4. Connect to mysql on this machine:

cdmysql\bin

mysql-uroot-p

Enter the password

Exit mysql command: exit

5, Change mysql password:

mysqladmin-u username-p old passwordpassword new password

or

mysql command line SETPASSWORDFORroot=PASSWORD(“root”);

6. Add new user

grantselecton database . *to username@loginhostidentifiedby “password”

eg: add a user test password 123, so that he can log in on any host, and all databases have the right to query, insert, modify, delete. First connect to mysql as root and type the following commands:

grantselect,insert,update,deleteon*. *to “Identifiedby “123”;7, about mysql database operations

Must first log into mysql, the operation is in mysql prompt, and each command to the end of the semicolon

Display the database list: showdatabases;

Show the database tables in the library: usus tables in the library: usemysql;//open library

showtables;

Show the structure of the data table: describe table name;

creating library: createdatabase library name;

creating table: use library name;

createtable table name ( field setting list);

delete library and delete table: dropdatabase library name;

droptable table name;

empty the table records: deletefrom table name;

display the records in the table: select*from table name;

8, coding changes

If you want to change the encoding format of the entire mysql:

Start mysql, mysqld_safe command line to add

–default-character-set=gbk

If you want to change the encoding format of a library: enter the command after the mysql prompt

alterdatabasedb_namedefaultcharactersetgbk;9, the import and export of data

Text data to the database

Text data should comply with the format: field data is separated by tab key, null value is used in place of. Example:

1namety2006-11-23

Data incoming command loaddatalocalinfile “filename” intotable table name;

10, export the database and tables

mysqlmp –optnews>news.sql (will) all tables in the database news backed up to the file news.sql, news.sql is a text file with any filename)

mysqlmp –optnewsauthorarticle>author.article.sql (backs up the author and article tables in the database news to the author.article.sql file, which is a text file with any name. text file with any file name.)

mysqlmp –databasesdb1db2>news.sql (Backup databases dbl and db2 to the news.sql file, news.sql is a text file with any filename.)

mysqlmp-hhost-uuser-ppass–databasesdbname>file.mp

That is, import the database dbname on host with name user and password pass into the file file.mp

mysqlmp– all-databases>all-databases.sql (Backup all databases to the file all-databases.sql, all-databases.sql is a text file with any name you want.)

11, Import data

mysql<all-databases.sql (import databases)

mysql>sourcenews.sql; (executed under the mysql command to import tables)

12, Connect to MySQL

Format: mysql-h host address-u username-p user password

Example 1: Connecting to MYSQL on this machine.

First, open a DOS window, and then go to the directory mysqlbin, and then type in the command mysql-uroot-p, and then enter the command, and then you will be prompted to lose the password, and if you just installed MYSQL, the super user root does not have a password. If you have just installed MYSQL, the superuser root does not have a password, so you can enter directly into the MYSQL, MYSQL prompt is: mysql>.

Example 2: Connect to MYSQL on a remote host, assuming that the remote host’s IP is 110.110.110.110, and that the user name is root, and the password is abcd123. Type the following command:

mysql-h110.110.110.110-uroot-pabcd123

(Note:u and root can be used without spaces, and the others are the same)

13. Quit MYSQL command: exit (enter).

14. Change password

Format: mysqladmin-u username-p old passwordpassword new password

Example 1: Add a password ab12 for root. first go to the directory mysqlbin under DOS, and then type the following command:

mysqladmin-uroot-passwordab12. uroot-passwordab12Note: Since root starts with no password, the -p old password item can be omitted.

Example 2: Change root’s password to djg345 again.

mysqladmin-uroot-pab12passworddjg34515. add a new user. (Note: Commands in the MySQL environment, so they are followed by a semicolon as a command terminator)

Format: grantselecton database. *to username@login host identifiedby\”password\”

Example 1: Add a user, test1, with password abc, so that he can log in on any host and have query, insertion, modification, and deletion privileges on all databases. First connect to MySQL as root and type the following commands:

grantselect,insert,update,

deleteon*. *totest1@\”%\”Identifiedby\”abc\”;But the user added in Example 1 is very dangerous, you want to such as someone who knows the password of test1, then he can log on to your MySQL database on any computer on the Internet and do whatever you want with your data, the solution is to see Example 2.

Example 2: Add a user test2 with the password abc, so that he can only log in on localhost and can query, insert, modify, and delete the database mydb (localhost means the local host, i.e., the host where the MySQL database is located), so that the user even if he knows the password of test2, he can’t access the database directly from the Internet. Internet, but only through a web page on the MySQL host.

grantselect,insert,update,

deleteonmydb.*totest2@localhostidentifiedby\”abc\”; If you don’t want test2 to have a password, you can type another command to eliminate the password.

grantselect,insert,update,deleteonmydb

How to use cmd commands to quickly start and shut down the mysql database service

In the development of MySQL database is often used, if the MySQL database service is not set to start automatically, you need to manually turn on the service and shut down the service, then how to use cmd commands to quickly start and shut down the mysql database service? The following is the specific method of operation, there is a need for friends can refer to understand:

Methods

Click on the computer to open the “Start” in the “Run” option, enter the command directly! “netstartmysql” and click “OK” (as shown below):

Click “OK” in the pop-up box that shows The “mysql database service” is starting (as shown below):

If you don’t know whether the MySQL service is on or not, you can test it by clicking on “Navicat”, executing the “query statement”, “Successful execution” indicates that “the service has been opened”, which means that through the “cmd “option, directly enter the command “netstopmysql” and click “OK” (as shown below):

Click “OK! After clicking “OK”, the pop-up box shows that the “mysql database service” is being stopped (shut down) (as shown below):

Testing that the MySQL service has been shut down, the same way, the use of Navicat to execute the query statement, it will be prompted with an error message. If you don’t know whether the MySQL service is closed, you can test it by clicking open “Navicat” and executing the “query statement”, which will prompt an error message, which means that the command “cmd” has been quickly stopped (closed) (as shown below). cmd” command has quickly shut down the “mysql database service” (the following chart):

You can also use “DOS commands” to start and stop the MySQL service on Windows, but you can’t restart it directly. service, but you can’t restart the “restartMySQL” service directly, you can only stop it first and then start it again (see below):

How to restart MySQL database (how to do it exactly)?

1, first click [Start]

2, then type cmd in the search bar and press enter,

3, type netstopmysql under cmd and enter,

4, at this time, it shows that mysql has stopped,

5, under the cmd type netstartmysql, and then enter,

6, at this time it shows that mysql has been started, reboot is complete, complete the effect of the picture.