Cmake安装MySQL数据方法

Cmake安装MySQ

  1. tar zxvf cmake-2.8.4.tar.gz  

  2. cd cmake-2.8.4  

  3. ./configure  --prefix=/usr/local/cmake  

  4. make && make install  

安装mysql5.5.13

  • groupadd mysql              //所以在这里我们要建一个msyql的用户和组  

useradd -g mysql mysql -s /usr/sbin/nologin   mkdir /usr/local/mysql           //创建目录   mkdir /usr/local/mysql/data

进入mysql-5.5.13的解压目录:

cmake -DCMAKE_INSTALL_PREFIX=/usr/local/mysql && make && make install

进入mysql的安装目录/usr/local/mysql下:

  • scripts/mysql_install_db --basedir=/usr/local/mysql --datadir=/usr/local/mysql/data --user=mysql  //初始化mysql数据库

cp support-files/my-medium.cnf /usr/local/mysql/my.cnf //copy配置文件   chown -R mysql:mysql /usr/local/mysql //更改权限      

vi /usr/local/mysql/my.cnf  //加上以下内容

[mysqld]

datadir=/usr/local/mysql/data

socket=/tmp/mysql.sock

user=mysql

symbolic-links=0

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

[mysql]

socket=/tmp/mysql.sock

~2.使用GRANT语句

mysql>grant all on *.* to 'root'@'localhost' IDENTIFIED BY '你的密码'   设置密码。

flush privileges; 刷新

grant all on *.* to root@'%' identified by '密码';  允许远程

[mysqld]    

basedir = /usr/local/mysql  

datadir = /usr/local/mysql/data  

log-error = /usr/local/mysql/mysql_error.log  

pid-file = /usr/local/mysql/mysql.pid  

user = mysql  

tmpdir          = /tmp  

启动mysql    bin/mysqld_safe --user=mysql & 或使用下列命令把mysql添加为系统服务。

  • cd /usr/local/mysql/support-files/  

cp ./mysql.server /etc/init.d/mysqld  /etc/init.d/mysqld start


你可能感兴趣的:(mysql,用户,local)