1. 安装
A 在线安装:yum install mysql-server
cp /usr/share/mysql/my-large.cnf /etc/my.cnf
B 离线安装:
tar -zxf mysql-5.1.51-linux-i686-glibc23.tar.gz //解压
mv /mysql-5.1.51-linux-i686-glibc23 /usr/local/mysql // 将解压后的文件放到指定位置(此位置不可变)
cp /usr/local/mysql/support-files/my-large.cnf /etc/my.cnf // my.cnf mysql基本信息配置文件
groupadd mysql
useradd mysql -g mysql
chown -R root.mysql /usr/local/mysql
cd /usr/local/mysql
./scripts/mysql_install_db --user=mysql
2.修改默认字符集
vim /etc/my.cnf 找到log-bin=mysql-bin这一行,将其注释:
#log-bin=mysql-bin
#binlog_format=mixed
在client下加入
default
-character-
set
=utf8
在mysqld下加入
default
-character-
set
=utf8
key_buffer_size = 256M
max_allowed_packet = 64M
3. 加入开机启动:
#cp /usr/local/mysql/support-files/mysql.server /etc/init.d/mysqld
cp /usr/share/mysql/mysql.server /etc/init.d/mysqld
chkconfig mysqld on (CentOs)
启动mysql: service mysqld start
设置本地登录密码mysqladmin -u root password 123456
进入数据库 /usr/local/mysql/bin/mysql -uroot -p
远程登录权限设置:grant all privileges on *.* to root
@"%"
identified by
'123456'
with grant option;
本地操作权限:grant all privileges on *.* to root
@"master"
identified by
'123456'
with grant option;
create database hive
常见问题
1、mysqld启动不了
错误提示:
[root@philix lib]# /usr/sbin/mysqld 060715 21:16:36 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root! 060715 21:16:36 [ERROR] Aborting 060715 21:16:36 [Note] /usr/sbin/mysqld: Shutdown complete
[root@philix lib]# /usr/sbin/mysqld 060715 21:16:36 [ERROR] Fatal error: Please read "Security" section of the manual to find out how to run mysqld as root! 060715 21:16:36 [ERROR] Aborting 060715 21:16:36 [Note] /usr/sbin/mysqld: Shutdown complete
解决办法:在/etc/my.conf中的mysqld加入
user=mysql
说明:这个错误本人今天刚好也碰到了,除了加入user=mysql,也可以试试用/usr/bin/mysqld_safe --user=mysql & 来启动,注意mysql目录的权限。
2、包冲突
用 yum remove ... 将冲突的包卸载 yum remove mysql-libs