Home Database Mysql Tutorial mysql多实例安装详解_MySQL

mysql多实例安装详解_MySQL

May 27, 2016 pm 02:12 PM
mysql ubuntu computer

bitsCN.com

首先说明一个场景:我的电脑是ubuntu系统,之前apt-get自动安装过mysql。这也是出现错误最多的原因之一。 

安装过程,其中充斥着各种错误: 
  1. 6.mkdir mysql  
  2. 7.groupadd mysql  
  3. 8.useradd -r -g mysql mysql  
  4. # make clean  
  5. # rm -f CMakeCache.txt  
  6. # rm -rf /etc/my.cnf  
  7. 9.cmake . -DCMAKE_INSTALL_PREFIX=/usr/local/mysql  
  8. -DMYSQL_DATADIR=/usr/local/mysql/data -DDEFAULT_CHARSET=utf8  
  9. -DDEFAULT_COLLATION=utf8_general_ci -DEXTRA_CHARSETS=all  
  10. -DENABLED_LOCAL_INFILE=1  
  11. make  
  12. make install  
这个表示mysql源码安装已经完成了,现在要做就是初始化用户了,也就是多实例中最重要的一部了,以后的每一步都要注意命令执行后的结果: 
  1. cd /usr/local/mysql  
  2. chown -R root:mysql .  
  3. chown -R mysql:mysql data  
  4. 11.cp support-files/my-medium.cnf /etc/my.cnf  
  5. 12.cd /usr/local/mysql  
  1. scripts/mysql_install_db --defaults-file=/usr/local/mysql/data_3308/my.cnf --datadir=/usr/local/mysql/data_3308/  
上面的mysql_install_db这个命令就是来进行初始化新用户。这里要注意命令执行后的结果,
  1. 第一次的时候我的执行结果是这样的:  
  2. root@zhou:/usr/local/mysql# scripts/mysql_install_db --defaults-file=/usr/local/mysql/data_3307/my.cnf --datadir=/usr/local/mysql/data_3307/  
  3. Installing MySQL system tables...  
  4. 130107 10:25:47 [ERROR] COLLATION 'latin1_swedish_ci' is not valid for CHARACTER SET 'utf8'  
  5. 130107 10:25:47 [ERROR] Aborting  
  6. 130107 10:25:47 [Note] /usr/local/mysql/bin/mysqld: Shutdown complete  
这里可以看出已经出现了错误,原因是什么,大家应该可以看明白了,自己太马虎了。导致自己重新执行了一次cmake 
然后重新进行上面的命令了。直到我们看到这样的结果:表示初始化成功了,恭喜你下面可以进行下面的操作了。 
  1. root@zhou:/usr/local/mysql# mysql_install_db --user=mysql --defaults-file=/usr/local/mysql/data3307/my.cnf --datadir=/usr/local/mysql/data3307/  
  2. Installing MySQL system tables...  
  3. OK  
  4. Filling help tables...  
  5. OK  
这时他会在我们的data目录中生成一些mysql库啊和test库等这些基本信息。 
对了要注意了,权限的分配,一不小心mysql的就无法读取相关文件的权利。 
  1. mysqld_safe --defaults-file=/usr/local/mysql/data_3307/my.cnf &  
  2. 130107 13:35:36 [Note] Server socket created on IP: '0.0.0.0'.  
  3. 130107 13:35:36 [ERROR] /usr/local/mysql/bin/mysqld: Can't find file: './mysql/host.frm' (errno: 13)  
  4. 130107 13:35:36 [ERROR] Fatal error: Can't open and lock privilege tables: Can't find file: './mysql/host.frm' (errno: 13)  
  5. 130107 13:35:36 mysqld_safe mysqld from pid file /usr/local/mysql/data3307/mysql.pid ended  
这里的错误也是很明显的原因就是我们没有读取host。frm的权限了,补救的办法又两种:一种是直接到目录下给mysql附上这样的权限,第二种就是追究它原因为什么会那样呢?原因是我们在初始化的时候,没有加入--user=mysql这个参数才导致生成的文件全市root权限。 
在下次做时,就需要这样的命令了: 
  1. root@zhou:/usr/local/mysql# mysql_install_db --user=mysql --defaults-file=/usr/local/mysql/data3307/my.cnf --datadir=/usr/local/mysql/data3307/ --user=mysql  
ok,这时我们可以通过命令来查看一下我们开通的服务个数,然后登录上去进行基本的操作,权限,键表啊,replication啊等等。 

这里启动了三个mysql服务器后,发现只能登录到3306上面的服务去,而其他的就是没法登录,当我把3307 3306杀掉后,登录mysql确出现错误了, 
  1. root@zhou:/usr/local/mysql/tmp# mysql  
  2. ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (111)  
错误原因:当在没有指定那个数据库服务器是它是有个默认启动计划,所以这里可以看出它还是在等待mysql 3306的那个服务器的。 
  1. root@zhou:/etc/init.d# mysql -h127.0.0.1 -P3307  
bitsCN.com
Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

AI Hentai Generator

AI Hentai Generator

Generate AI Hentai for free.

Hot Article

R.E.P.O. Energy Crystals Explained and What They Do (Yellow Crystal)
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. Best Graphic Settings
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌
R.E.P.O. How to Fix Audio if You Can't Hear Anyone
2 weeks ago By 尊渡假赌尊渡假赌尊渡假赌

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

The page is blank after PHP is connected to MySQL. What is the reason for the invalid die() function? The page is blank after PHP is connected to MySQL. What is the reason for the invalid die() function? Apr 01, 2025 pm 03:03 PM

The page is blank after PHP connects to MySQL, and the reason why die() function fails. When learning the connection between PHP and MySQL database, you often encounter some confusing things...

How to efficiently integrate Node.js or Python services under LAMP architecture? How to efficiently integrate Node.js or Python services under LAMP architecture? Apr 01, 2025 pm 02:48 PM

Many website developers face the problem of integrating Node.js or Python services under the LAMP architecture: the existing LAMP (Linux Apache MySQL PHP) architecture website needs...

How to jump from Word plug-in to browser for login authorization? How to jump from Word plug-in to browser for login authorization? Apr 01, 2025 pm 08:27 PM

How to achieve login authorization from within the application to outside the application? In some applications, we often encounter the need to jump from one application to another...

How to implement cross-application jump for Word plug-in login authorization? How to implement cross-application jump for Word plug-in login authorization? Apr 01, 2025 pm 11:27 PM

How to implement cross-application jump for Word plug-in login authorization? When using certain Word plugins, we often encounter this scenario: click on the login in the plugin...

How to implement hot reload in Debian How to implement hot reload in Debian Apr 02, 2025 am 07:54 AM

Experience the convenience of Flutter hot reloading on the Debian system, just follow the steps below: Install FlutterSDK: First, you need to install FlutterSDK on the Debian system. Visit Flutter official website to download the latest stable version of SDK and decompress to the specified directory (for example, ~/flutter). After that, add Flutter's bin directory to the system PATH environment variable. Edit the ~/.bashrc or ~/.profile file, add the following code: exportPATH="$PATH:~/flutter/bin" Save the file and execute source~/.bas

Is Debian Strings compatible with multiple browsers Is Debian Strings compatible with multiple browsers Apr 02, 2025 am 08:30 AM

"DebianStrings" is not a standard term, and its specific meaning is still unclear. This article cannot directly comment on its browser compatibility. However, if "DebianStrings" refers to a web application running on a Debian system, its browser compatibility depends on the technical architecture of the application itself. Most modern web applications are committed to cross-browser compatibility. This relies on following web standards and using well-compatible front-end technologies (such as HTML, CSS, JavaScript) and back-end technologies (such as PHP, Python, Node.js, etc.). To ensure that the application is compatible with multiple browsers, developers often need to conduct cross-browser testing and use responsiveness

xml online formatting xml online formatting Apr 02, 2025 pm 10:06 PM

XML Online Format Tools automatically organizes messy XML code into easy-to-read and maintain formats. By parsing the syntax tree of XML and applying formatting rules, these tools optimize the structure of the code, enhancing its maintainability and teamwork efficiency.

Jiutian Computing Power Platform Task: Will the computing task continue to run after the local computer is shut down? Jiutian Computing Power Platform Task: Will the computing task continue to run after the local computer is shut down? Apr 01, 2025 pm 11:57 PM

Discussion on the task status after the local computer of Jiutian Computing Power Platform is closed. Many users will encounter a question when using Jiutian Computing Power Platform for artificial intelligence training...

See all articles