centos之MySQL5.5二进制安装

环境:CentOs6.5
服务器:腾讯云

安装依赖包
yum -y install make gcc-c++ cmake bison-devel ncurses-devel libaio libaio-devel perl

下面两个是centos7需要的依赖
//yum install perl-Data-Dumper -y
//yum install net-tools -y

cd /usr/local/src
wget http://dev.mysql.com/get/Downloads/MySQL-5.5/mysql-5.5.32-linux2.6-x86_64.tar.gz
tar -zxvf mysql-5.5.32-linux2.6-x86_64.tar.gz
mv mysql-5.5.32-linux2.6-x86_64 /usr/local/mysql
cd /usr/local/mysql
useradd -s /sbin/nologin mysql //创建一个安全的用户
mkdir -p /data/mysql //自定义数据库
chown -R mysql:mysql /data/mysql //修改目录属主

初始化数据库
./scripts/mysql_install_db –user=mysql –datadir=/data/mysql

cp support-files/my-medium.cnf /etc/my.cnf               //复制mysql配置文件
cp support-files/mysql.server /etc/init.d/mysqld               //生成mysql启动脚本
chmod 755 /etc/init.d/mysqld

vim /etc/init.d/mysqld
修改字段datadir=/data/mysql(这个不写启动不了)

chkconfig –add mysqld                                   //把MySQL服务加入系统
chkconfig mysqld on                                            //设置开机自启

echo “export PATH=$PATH:/usr/local/mysql/bin” >>/etc/profile           //加入环境变量
source /etc/profile                                                //更新环境变量

启动MySQL

service mysqld start

mysqladmin -uroot password 123456                                 //设置mysql管理员密码
mysql -e “grant all privileges on . to root@’%’ identified by ‘123456’”     // 给远程连接用户授权:

#mysql -uroot -p123456                                                                   //本地登陆
#mysql -uroot -h 118.184.181.22 -P 3310 -p123456                      //远程登陆

忘记或更改MySQL用户密码:

vim /etc/my.cnf        

 [mysqld]

skip-grant-tables

service mysqld restart 

 

mysql -e "use mysql;update user set password=password('123456') where user='root';"

mysql -e "flush privileges;"

#改完之后/etc/my.cnf添加的一行skip-grant-tables要注释掉.

企业有时需要开启独立表空间

  1. mysql> set global innodb_file_per_table =ON;  
  2. mysql> show variables like '%per_table%'; 

还有禁止mysql做域名解析
[mysqld]
skip-name-resolve

到此完毕!

猜你喜欢

转载自blog.csdn.net/sinat_33230211/article/details/82421718
今日推荐