MySQL RPM包安装和相关操作

来源:互联网 发布:软件测试师考试 编辑:程序博客网 时间:2024/06/06 11:00

1.    Mysql

下载

http://ftp.ntu.edu.tw/pub/MySQL/Downloads/

http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.5/MySQL-server-5.5.32-1.sles11.x86_64.rpm

http://ftp.ntu.edu.tw/pub/MySQL/Downloads/MySQL-5.5/MySQL-client-5.5.32-1.sles11.x86_64.rpm

 

安装

添加用户和用户组

#groupadd mysql

#useradd  -m -d /home/mysql  -s/bin/sh  -g mysql mysql

#useradd -m -g mysql {username};echo "Password"|passwd--stdin {username}

 

删除旧mysql:

查看mysqlrpm包:

#rpm -qa|grep -i mysql

发现mysql-client-5.5.31-0.7.10

卸载

#rpm -e --nodeps mysql-client-5.5.31-0.7.10

然后删除配置文件和旧数据

#rm -f /etc/my.cnf

#rm -rf /var/lib/mysql

删除老版本mysql的开发头文件和库

#rm -rf /usr/lib/mysql

#rm -rf /usr/include/mysql

 

安装Mysql服务器端

#rpm -ivhMySQL-server-5.5.32-1.sles11.x86_64.rpm --nodeps --force

#rpm -ivhMySQL-client-5.5.32-1.sles11.x86_64.rpm --nodeps --force

 

配置$PATH

#/etc/profile

#export PATH=/usr/share/mysql/:$PATH

#EOF

 

配置my.cnf

#vim /etc/my.cnf

添加

[mysqld]

#

default-storage-engine = innodb

character-set-server = utf8

collation-server = utf8_unicode_ci

init-connect='SET NAMES utf8'

[client]

default-character-set=utf8

[mysql]

default-character-set=utf8

重启mysql.server使配置生效

mysql.server restart

 

自动启动

#cp /usr/share/mysql/mysql.server/etc/init.d/

#chmod +x /etc/init.d/mysql.server

#chkconfig --add mysql.server

启动Mysql服务

#/etc/init.d/mysql.server start

(若启动时报错StartingMySQL.The server quit without updating PID file (/var/lib/mysql/linux-79vf.pid,由于/etc/my.cnf配置有误。删掉my.cnf后再启动mysql)

 

给mysql用户添加密码

#/usr/bin/mysqladmin -uroot password {password}

修改密码

#/usr/bin/mysqladmin -uroot –p{password}password {new_password}

 

登陆

#mysql -uroot -p{password}

远程登陆

#mysql -h10.101.1.xxx -uroot -p{password}

 

开启用户远程访问mysql服务器权限

服务器端:

mysql>GRANT ALL ON *.* TO {username}@'10.101.1.xx'IDENTIFIED BY '{password}';

FLUSH PRIVILEGES;

其他语句:

GRANT ALL ON db.* TO root@'%' IDENTIFIED BY'{password}';

GRANT ALL ON db.* TO root@'localhost'IDENTIFIED BY '{password}';

客户端:

mysql -h10.101.1.1xx -uroot -p{password}

 

查看存储过程:

mysql>show procedure status where db=”xxx”;

查看存储过程代码:

mysql>use xxx;  //存储过程所在的数据库

mysql>show create procedure sp_name;

 

查看Linux版本

#cat /proc/version

查看32位还是64位

#file /sbin/init

yum源

/etc/yum.repos.d/

查看glibc版本

#ldd –version

查看mysql版本

#mysql --version

 

xshell无法连上

关闭SUSE防火墙

#/sbin/SuSEfirewall2 stop

永久关闭(当前运行级别为3)

#chkconfig --level 3 SuSEfirewall2_setupoff

#chkconfig --level 3 SuSEfirewall2_initoff

 

查看rpm的默认安装路径

#rpm -pqlMySQL-server-5.5.32-1.sles11.x86_64.rpm

0 0