Create a MySQL instance

Source: Internet
Author: User

1. Add the content to/etc/My. CNF.

[Mysqld_dev]
Socket =/tmp/MySQL. Sock
Port = 3307
PID-file =/var/run/mysqld/mysqld_dev.pid
Datadir =/var/lib/mysql_dev
Log =/var/log/mysqld_dev.log
Log-error =/var/log/mysqld_dev.err.log
User = MySQL

2. Create directories and files based on the above content

Mkdir/var/lib/mysqld_dev

Chown MYSQL: MySQL/var/lib/mysqld_dev

...

3. write/etc/rc. d/init. d/mysqld_dev, or from/etc/rc. d/init. d/mysqld copy, and modify the code for obtaining parameters.

Get_mysql_option mysqld_dev datadir "/var/lib/MySQL"
Datadir = "$ result"
Get_mysql_option mysqld_dev socket "$ datadir/MySQL. Sock"
Socketfile = "$ result"
Get_mysql_option mysqld_dev log-error "/var/log/mysqld. log"
Errlogfile = "$ result"
Get_mysql_option mysqld_dev pid-file "/var/run/mysqld. pid"
Mypidfile = "$ result"

 

4. Start server

Servie mysqld_dev start

Error detected

Mysqld_safe [ERROR] Fatal error: Can't open and lock privilege tables: Table 'mysql. host' doesn' t exist

You must use mysql_install_db to create a system table.

Mysql_install_db -- user = mysql -- datadir =/var/lib/mysql_dev/

Restart again, successful

 

5. Use mysql-u root-S/tmp/mysql. sock to connect to this instance.

6. If you do not want to write-S/tmp/mysql_dev.sock, you can add the code in [client] Of my. cnf to set the default sock.

[Client]
Socket =/tmp/mysql_dev.sock
 

 

 

 

 

This article is created by happy writers

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.