2014-11-25 01:18:10
来 源
中存储网
Linux
64位Ubuntu系统中安装配置MySQL5.6.10数据库具体步骤:添加用户和用户组(我的都为htt,并且之前都已经有了):stor.com.cn@:~$ sudo groupadd stor。

64位Ubuntu系统中安装配置MySQL5.6.10数据库的过程分享:

添加用户和用户组(我的都为htt,并且之前都已经有了):

stor.com.cn@:~$ sudo groupadd htt
[sudo] password for htt: 
groupadd: group 'htt' already exists
stor.com.cn@:~$ sudo useradd -r -g htt htt
useradd: user 'htt' already exists
stor.com.cn@:~$
进入到/usr/local:

stor.com.cn@:~$ cd /usr/local
解压mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz到/usr/local:

stor.com.cn@:/usr/local$ sudo tar zxvf /home/htt/下载/mysql-5.6.10-linux-glibc2.5-x86_64.tar.gz
创建链接mysql指向mysql-5.6.10-linux-glibc2.5-x86_64目录:
stor.com.cn@:/usr/local$ sudo ln -s mysql-5.6.10-linux-glibc2.5-x86_64 mysql
修改环境变量:

stor.com.cn@:/usr/local/mysql$ gedit ~/.bashrc
在文件末尾添加如下代码(将mysql目录下bin目录加入到path中):

# MYSQL
export MYSQL_HOME=/usr/local/mysql
export PATH=${MYSQL_HOME}/bin:$PATH

保存关闭该文件,终端输入:

stor.com.cn@:/usr/local/mysql$ source ~/.bashrc
进入到mysql:
stor.com.cn@:/usr/local$ cd mysql
修改目录下所有内容的用户和用户组:

stor.com.cn@:/usr/local/mysql$ sudo chown -R htt .
stor.com.cn@:/usr/local/mysql$ sudo chgrp -R htt .
运行mysql_install_db(首次安装运行一次即可,更新安装不需要):
stor.com.cn@:/usr/local/mysql$ scripts/mysql_install_db --user=htt --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data
如果报如下错误:

 MySQL system tables.../usr/local/mysql/bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
则解决方法为:
stor.com.cn@:/usr/local/mysql$ sudo apt-get install libaio1 libaio-dev
修改文件用户为root,data目录的保留:
stor.com.cn@:/usr/local/mysql$ sudo chown -R root .
stor.com.cn@:/usr/local/mysql$ sudo chown -R htt data
开启MySQL服务
stor.com.cn@:/usr/local/mysql$ bin/mysqld_safe --user=htt &
显示信息如下:

[1] 10608
stor.com.cn@:/usr/local/mysql$ 130303 20:22:26 mysqld_safe Logging to '/usr/local/mysql/data/htt-Lenovo-V470c.err'.
130303 20:22:26 mysqld_safe Starting mysqld daemon with databases from /usr/local/mysql/data
用bin/mysqladmin难验证服务是否已经开启:

stor.com.cn@:/usr/local/mysql$ bin/mysqladmin version
或(bin目录已加入环境变量)stor.com.cn@:~$ mysqladmin version
显示结果如下:
bin/mysqladmin  Ver 8.42 Distrib 5.6.10, for linux-glibc2.5 on x86_64
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Server version              5.6.10
Protocol version    10
Connection              Localhost via UNIX socket
UNIX socket              /tmp/mysql.sock
Uptime:                    2 min 46 sec
Threads: 1  Questions: 2  Slow queries: 0  Opens: 67  Flush tables: 1  Open tables: 60  Queries per second avg: 0.012
再输入如下代码:

stor.com.cn@:~$ mysqladmin variables
显示一系列形如以下的变量信息:

……
| slow_query_log_file                | /usr/local/mysql/data/htt-Lenovo-V470c-slow.log  
| socket                             | /tmp/mysql.sock
……
此时可以确定服务已正常开启。
关闭服务
stor.com.cn@:~$ mysqladmin -u root shutdown
130303 22:18:28 mysqld_safe mysqld from pid file /usr/local/mysql/data/htt-Lenovo-V470c.pid ended
[1]+  完成                  mysqld_safe --user=htt
验证服务是否关闭:
stor.com.cn@:~$ mysqladmin version
显示信息如下:
mysqladmin: connect to server at 'localhost' failed
error: 'Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)'
Check that mysqld is running and that the socket: '/tmp/mysql.sock' exists!
每次MySQL服务开启时都会创建一个mysql.sock文件,关闭时删除之,参考。

声明: 此文观点不代表本站立场;转载须要保留原文链接;版权疑问请联系我们。