Database mysql/mariadb Knowledge Point--operation chapter (0) Start

Source: Internet
Author: User
Tags mysql commands rehash server port

Start the database

The usual statements to start MySQL or stop MySQL are as follows:

1. Start the service:

CENTOS6:

Service mysqld Start

CENTOS7:

Systemctl Start mysqld

2. Restart the service:

CENTO6:

Service mysqld Restart

CENTOS7:

Systemctl Restart Mysqld

3. Close the service:

CENTO6:

Service Mysqld Stop

CENTOS7:

Systemctl Stop Mysqld
Related configuration Files

Master profile : Check from top to bottom, if there are duplicate configuration parameters then the parameters in the following configuration file take effect, overwrite the search

1 /etc/my.cnf2 /etc/mysql/my.cnf3 /etc/sysconfig/my.cnf  4 /usr/local/etc/my.cnf5 ~/.my.cnf
my.cnf

To view the default configuration:

/usr/libexec/mysqld--print-defaults

Default database library file storage directory:

/var/lib/mysql/

Socket file

/var/lib/mysql/mysql.sock

PID File

/var/run/mariadb/mariadb.pid

Log file

/var/log/mariadb/mariadb.log

  

Database management System (DBMS)

MySQL database is a kind of c\s structure software, which is divided into: client and server.

If you want to access the server, you must go through the client, the server should be running, and the client will run when it needs to be used.

Connecting to a database

1. Local connection

Mysql-u User name-p password
For example:
mysql-uroot-p123456

Where-u and the user name root can have a space between-p and the password must not exist between the space.

2. Remote connection

Mysql-u User name-p password-H IP address-p port number
For example
Mysql-u root-p123456-h 192.168.1.103-p 3306

We can also specify a database for specific logins at the time of connection, such as specifying a connection to the TestDB database

mysql-uroot-p123456-d TestDB

When you connect to MySQL locally, you can specify that you connect to the database through a specific socket file

Mysql-uroot-p123456-s/var/lib/mysql/mysql.sock

Executes the corresponding command at the same time as the database is connected and returns the command result without entering the MySQL prompt; non-interactive mode

Mysql-uroot-p123123-e ' use MySQL; Select User,host,password from user; ' Mysql-uroot-p123123-e ' CREATE database if not exists testdb; show databases; '

Common options for databases

1-A,--no-auto-rehash prohibition of full complement2-U,--user=user name, default is root3-H,--host=server host, default to localhost4-p,--passowrd= user password, recommended use-p, default is blank password5-P,--port=Server Port6-S,--socket=specify the path of the socket file to connect7-D,--database=Specify the default database8-C,--Compress enable compression9-e "SQL" Execute SQL commandTen-V,--version Display versions One-V--Verbose Show Details A--print-defaults get the configuration that the program uses by default
Options

Note:

1, Prompt \[email protected][\d] \r:\m:\s-> Modify the prompt, if you need to permanently modify the my.cnf in [MySQL] under the add

Prompt= "(\[email protected]\h) [\d]>

2, batch processing, the SQL Script import library execution

MySQL </path/somefile.sql
Get help

Use Help for assistance

1MariaDB [(None)]> Help2 3 General information about MariaDB can is found at4http//mariadb.org5 6 List of all MySQL commands:7Note that all text commands must is first on line and end with';'8? (\?) Synonym for' Help'.9 Clear(\c) Clear the current input statement.Ten connect (\ r) reconnect to the server. Optional arguments is DB and host. One delimiter (\d) Set statement delimiter. A Edit command with $EDITOR. \e. - Ego (\g) Send command to MySQL server, display result vertically. - exit (\q) exit MySQL. Same as quit. the Go (\g) Send command to MySQL server. - Help (\h) Display. - Nopager (\ n) Disable Pager, print to stdout. -Notee (\ t) Don'T write into outfile. + Pager (\p) Set Pager [To_pager]. Print the query results via PAGER. - print (\p) print current command. + prompt (\ r) Change your MySQL prompt. A quit (\q) quit MySQL. at Rehash (\#) Rebuild completion hash. -Source (\.) Execute an SQL scriptfile. Takes Afilename as an argument. - status (\s) Get status information from the server. -System (\!) Execute a system shell command. - Tee(\ t) Set outfile [To_outfile]. Append everything into given outfile. - Use (\u) use another database. Takes database name as argument. inCharSet (\c) Switch to another charset. Might be needed forProcessing Binlog with multi-bytecharsets. - warnings (\w) Show warnings after every statement. toNowarning (\W) Don'T show warnings after every statement. +  -For server side Help, type'Help Contents'
Help

Database mysql/mariadb Knowledge Point--operation chapter (0) Start

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.