下载地址:http://dev.mysql.com/downloads/mysql/5.6.html#downloads
下载版本:我这里选择的5.6.33,通用版,linux下64位
也可以直接复制64位的下载地址,通过命令下载:wget http://dev.mysql.com/get/Downloads/MySQL-5.6/mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz
2、解压
?
1234
#解压tar -zxvf mysql-5.6.33-linux-glibc2.5-x86_64.tar.gz#复制解压后的mysql目录cp -r mysql-5.6.33-linux-glibc2.5-x86_64 /usr/local/mysql
3、添加用户组和用户
?
1234
#添加用户组groupadd mysql#添加用户mysql 到用户组mysqluseradd -g mysql mysql
4、安装
?
123456789101112131415161718192021222324252627282930
cd /usr/local/mysql/<br>mkdir ./data/mysqlchown -R mysql:mysql ././scripts/mysql_install_db --user=mysql --datadir=/usr/local/mysql/data/mysqlcp support-files/mysql.server /etc/init.d/mysqldchmod 755 /etc/init.d/mysqldcp support-files/my-default.cnf /etc/my.cnf #修改启动脚本vi /etc/init.d/mysqld #修改项:basedir=/usr/local/mysql/datadir=/usr/local/mysql/data/mysql #启动服务service mysqld start #测试连接./mysql/bin/mysql -uroot #加入环境变量,编辑 /etc/profile,这样可以在任何地方用mysql命令了export PATH=$PATH:/usr/local/mysql//bin<br>source /etc/profile #启动mysqlservice mysqld start#关闭mysqlservice mysqld stop#查看运行状态service mysqld status
5、错误
5.1 sqlyog连接时,报1130错误,是由于没有给远程连接的用户权限问题
解决1:更改 ‘mysql’数据库‘user’表‘host’项,从‘localhost’改成‘%’。
use mysqlselect 'host' from user where user='root'
update user set host = '%' where user ='root'
flush privileges
解决2:直接授权
GRANT ALL PRIVILEGES ON *.* TO ‘root’@'%’ IDENTIFIED BY ‘youpassword’ WITH GRANT OPTION
5.2 安装时的一些错误
-bash: ./scripts/mysql_install_db: /usr/bin/perl: bad interpreter: 没有那个文件或目录
解决: yum -y install perl perl-devel
Installing MySQL system tables..../bin/mysqld: error while loading shared libraries: libaio.so.1: cannot open shared object file: No such file or directory
解决:yum -y install libaio-devel
6、其他
6.1 配置环境变量
vi + /etc/profile
export PATH=....:/usr/local/mysql/bin
免编译版本的MySQL很方便,省了好多时间,我用的是mysql5.5-x86_64版本,接下来是在CentOS6.5安装过程,就那么几个步骤。#安装依赖包
yum install -y libaio-devel
#创建用户
useradd -s /sbin/nologin mysql
#创建数据目录
mkdir -p /data/mysql
#赋予权限
chown -R mysql:mysql /data/mysql
#解压
tar zxvf mysql-5.5.42-linux2.6-x86_64.tar.gz
#移动到指定目录
mv mysql-5.5.42-linux2.6-x86_64 /usr/local/mysql
#因为系统有一个默认my.cnf,咱们给它改下名字
mv /etc/my.cnf /etc/my.cnf.default
#复制我们需要的my.cnf到指定目录
cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf
#在support-files目录下有几个cnf,根据内存大小来选择
my-small.cnf (内存<=64M)
my-medium.cnf (内存128M)
my-large.cnf (内存512M)
my-huge.cnf (内存1G-2G)
my-innodb-heavy-4G.cnf (内存4GB)
#编辑我们复制过去的my.cnf,并且在[mysqld]的下一行那里插入以下内容
vi /etc/my.cnf
[mysqld]
basedir=/usr/local/mysql
datadir=/data/mysql
character-set-server=utf8
#添加环境变量,在末尾插入以下内容
vi /etc/profile
PATH=/usr/local/mysql/bin:$PATH
export PATH
#让刚才的修改生效
source /etc/profile
#复制启动脚本到指定目录
cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
#准备工作都做完了,开始初始化数据库
/usr/local/mysql/scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/data/mysql --user=mysql
#启动数据库
service mysqld start
#开机启动
chkconfig mysqld on
#初始化mysql的一些设置
mysql_secure_installation
#回车
Enter current password for root (enter for none):
#y,设置mysql的root密码
Set root password?[Y/n] y
#以下都yes
Remove anonymous users?[Y/n] y
Disallow root login remotely?[Y/n] y
Remove test database and access to it?[Y/n] y
Reload privilege tables now?[Y/n] y
ThanksforusingMySQL!
OK,完成。
1、mysql一般存放在/usr/local/mysql/bin2、也可以将/usr/local/mysql/bin添加到PATH环境变量,例如
在~/.bash_profile增加
PATH=$PATH:$HOME/bin:/usr/local/mysql/bin
export PATH
3、重新登陆或者执行source ~/.bash_profile让变量生效
env|grep PATH
4、执行mysql -uroot -p测试即可
5、或者cd /usr/local/mysql/bin执行
./mysql -uroot -p
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)