码迷,mamicode.com
首页 > 数据库 > 详细

mysql在centos上的安装与配置

时间:2015-04-27 15:34:21      阅读:137      评论:0      收藏:0      [点我收藏+]

标签:mysql

groupadd mysql

useradd -r -g mysql mysql

mv mysql-5.5.27-linux2.6-i686/ /usr/local/

ln -s mysql-5.5.27-linux2.6-i686/ mysql

cd /usr/local/mysql

chown -R mysql .

chgrp -R mysql .

/usr/local/mysql/scripts/mysql_install_db --user=mysql


ERROR:

scripts/mysql_install_db: ./bin/my_print_defaults: /lib/ld-linux.so.2: bad ELF interpreter: No such file or directory

Neither host ‘host-1‘ nor ‘localhost‘ could be looked up with

./bin/resolveip

Please configure the ‘hostname‘ command to return a correct

hostname.

If you want to solve this at a later stage, restart this script

with the --force option



yum install glibc.i686

yum install zlib.i686

yum install libgcc.i686

#与mysql的版本对应,下载libaio-0.3.107-10.el6.i686.rpm安装

rpm -ivh libaio-0.3.107-10.el6.i686.rpm 


chown -R root:root ./

chown -R mysql:mysql data


cp support-files/mysql.server /etc/init.d/mysql

service mysql start

ps -ef|grep mysql 


#修改mysql的root用户密码,root初始密码为空的:

执行命令:./bin/mysqladmin -u root password ‘密码‘


# ‘Can‘t connect to local MySQL server through socket ‘/tmp/mysql.sock‘

# find / -name mysql.sock

# /var/lib/mysql/mysql.sock,执行以下命令后再重置密码Ok,

ln -s /var/lib/mysql/mysql.sock /tmp/mysql.sock


Error:

# ./bin/mysql -uroot -p

./bin/mysql: error while loading shared libraries: libncurses.so.5: cannot open shared object file: No such file or directory

安装两个包后解决:

yum install libstdc++.so.6 

yum install libncurses.so.5


授权root远程登录

mysql>GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ WITH GRANT OPTION

mysql>FLUSH PRIVILEGES


#Mysql初始化root密码和允许远程访问


mysql默认root用户没有密码,输入mysql –u root 进入mysql


1、初始化root密码

进入mysql数据库

mysql>update user set password=PASSWORD(‘123456’) where User=‘root‘;


2、允许mysql远程访问,可以使用以下三种方式:


a、改表。

mysql -u root –p

mysql>use mysql;

mysql>update user set host = ‘%‘ where user = ‘root‘;

mysql>select host, user from user;


b、授权。

例如,你想root使用123456从任何主机连接到mysql服务器。

mysql>GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ IDENTIFIED BY ‘123456‘ WITH GRANT OPTION;

如果你想允许用户jack从ip为10.10.50.127的主机连接到mysql服务器,并使用654321作为密码

mysql>GRANT ALL PRIVILEGES ON *.* TO ‘jack‘@’10.10.50.127’ IDENTIFIED BY ‘654321‘ WITH GRANT OPTION;

mysql>FLUSH RIVILEGES

c:在安装mysql的机器上运行:

//进入MySQL服务器

d:\mysql\bin\>mysql -h localhost -u root

//赋予任何主机访问数据的权限

mysql>GRANT ALL PRIVILEGES ON *.* TO ‘root‘@‘%‘ WITH GRANT OPTION

//使修改生效

mysql>FLUSH PRIVILEGES

//退出MySQL服务器

mysql>EXIT





mysql在centos上的安装与配置

标签:mysql

原文地址:http://8409200.blog.51cto.com/8399200/1638970

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!