日期:2014-05-16 浏览次数:20878 次
sudo groupadd mysql sudo useradd -r -g mysql mysql
tar –zxvf mysql-5.1.56-linux-i686-glibc23.tar.gz sudo mv mysql-5.1.56-linux-i686-glibc23 /usr/local/mysql51
//相当于cd /usr/local/mysql51 和cd /usr/local/mysql等效 sudo ln -s /usr/local/mysql51 mysql cd /usr/local/mysql
cd /usr/local/mysql //注意后面有小数点 sudo chown -R mysql . //将组属性改为mysql组。 sudo chgrp -R mysql .
//为了更改以上几个文件的权限,需要执行下面的命令。 guangbo@guangbo-laptop:/usr/local/mysql/lib$ sudo chown -h mysql:mysql libmysqlclient.so.16 libmysqlclient.so libmysqlclient_r.so.16 libmysqlclient_r.so
sudo scripts/mysql_install_db --user=mysql //将文件的所有属性改为root用户。 sudo chown -R root . //将数据目录的所有属性改为mysql用户。 sudo chown -R mysql data //下面这条给所有人弄data的权限,仅为了方便调试,不需要 sudo chmod a+rwx -R data //下面的命令可选。copy配置文件到相关目录 sudo cp support-files/my-medium.cnf /etc/my.cnf 启动mysql sudo bin/mysqld_safe --user=mysql & //下面的命令可选。开机自启动mysql.server服务. //To start mysqld at boot time you have to copy //support-files/mysql.server to the right place for your system sudo cp support-files/mysql.server /etc/init.d/mysql.server service mysql.server start //查看启动是否正常 ./bin/mysqladmin version./bin/mysqladmin Ver 8.42 Distrib 5.1.56, for pc-linux-gnu on i686
guangbo@guangbo-laptop:/usr/local/mysql$ ./bin/mysqladmin -u root -p password ='root'
//不能通过localhost和127.0.0.1。只能是服务器名。 mysql -h guangbo-laptop -u root –p //添加新ip mysql>INSERT INTO user (Host,User,Password) VALUES('192.168.1.2','root',PASSWORD('root')); mysql>FLUSH PRIVILEGES; //给某ip授权 mysql>GRANT ALL ON *.* TO root@'192.168.1.2' IDENTIFIED BY 'root' WITH GRANT OPTION; //root用户可以在所有ip访问 mysql>GRANT ALL ON *.* TO root@'%' IDENTIFIED BY 'root' WITH GRANT OPTION