安装包下载 MySQL-community-5.1.73-1.rhel5.x86_64.rpm-bundle.tar
需要安装
MySQL-server-community-5.1.73-1.rhel5.x86_64.rpm
MySQL-client-community-5.1.73-1.rhel5.x86_64.rpm
安装了client,在服务器上才能用mysql命令连接到mysql服务器
本人采用mysql用户安装的,用sudo rpm
linux下mysql5.1卸载 rpm
添加mysql组
[root@dev soft]# groupadd mysql
添加mysql用户
[root@dev soft]# useradd -g mysql mysql
[root@dev /]# cd /soft
[root@dev soft]# mkdir mysql-5.1.73
把MySQL-community-5.1.73-1.rhel5.x86_64.rpm-bundle.tar上传至此目录
改变目录及以下文件的所有者
[root@dev soft]# chown -R mysql ./mysql-5.1.73/
切换用户
[root@dev soft]# su - mysql
[mysql@dev ~]$# cd /soft/mysql-5.1.73
对用户加执行权限
[mysql@dev mysql-5.1.73]$ chmod u+x MySQL-community-5.1.73-1.rhel5.x86_64.rpm-bundle.tar
解压文件
[mysql@dev mysql-5.1.73]$ tar -xvf MySQL-community-5.1.73-1.rhel5.x86_64.rpm-bundle.tar
MySQL-community-debuginfo-5.1.73-1.rhel5.x86_64.rpm
MySQL-embedded-community-5.1.73-1.rhel5.x86_64.rpm
MySQL-client-community-5.1.73-1.rhel5.x86_64.rpm
MySQL-shared-compat-5.1.73-1.rhel5.x86_64.rpm
MySQL-server-community-5.1.73-1.rhel5.x86_64.rpm
MySQL-devel-community-5.1.73-1.rhel5.x86_64.rpm
MySQL-shared-community-5.1.73-1.rhel5.x86_64.rpm
MySQL-test-community-5.1.73-1.rhel5.x86_64.rpm
对用户加执行权限
[mysql@dev mysql-5.1.73]$ chmod u+x ./*
安装mysql服务器
非root用户用rpm命令安装会报如下错误[mysql@dev soft]$ rpm - ivh MySQL-server-community-5.1.73-1.rhel5.x86_64.rpm
error: can't create transaction lock on /var/lib/rpm/__db.000
非root用户使用rpm可以采用 sudo 命令 的方式,sudo 需要配置
[mysql@dev mysql-5.1.73]$ sudo rpm -ivh MySQL-server-community-5.1.73-1.rhel5.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-server-community ########################################### [100%]
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/usr/bin/mysqladmin -u root password 'new-password'
/usr/bin/mysqladmin -u root -h dev password 'new-password'
Alternatively you can run:
/usr/bin/mysql_secure_installation
which will also give you the option of removing the test
databases and anonymous user created by default. This is
strongly recommended for production servers.
See the manual for more instructions.
Please report any problems with the /usr/bin/mysqlbug script!
Starting MySQL..[确定]
Giving mysqld 2 seconds to start
查看服务是否启动
[mysql@dev mysql-5.1.73]$ netstat -nat
Active Internet connections (servers and established)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
安装客户端
[mysql@dev mysql-5.1.73]$ sudo rpm -ivh MySQL-client-community-5.1.73-1.rhel5.x86_64.rpm
Preparing... ########################################### [100%]
1:MySQL-client-community ########################################### [100%]
连接服务器端,此时root的密码是空,所以只用写mysql就可以
[mysql@dev mysql-5.1.73]$ mysql
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1
Server version: 5.1.73-community MySQL Community Server (GPL)
Copyright (c) 2000, 2013, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> exit
Bye
设置root用户的密码
[mysql@dev mysql-5.1.73]$ mysqladmin -u root password "password"
修改密码后客户端登录
[mysql@dev mysql-5.1.73]$ mysql -u root -p
Enter password:
mysql修改root 可以远程访问,两种方式
1.通过授权命令
mysql> GRANT ALL PRIVILEGES ON *.* TO 'root'@'%' IDENTIFIED BY 'password' WITH GRANT OPTION;
此操作会在user表插入一条新的记录。
2.直接改表
mysql> UPDATE user SET Host='%' WHERE User='root' AND Host='localhost' LIMIT 1;
刷新权限
mysql> flush privileges;
安装好后还要做一些配置,如设置编码
linux下mysql5.1的配置 rpm
其他操作
创建数据库
mysql> create database ucms;
创建用户,%表示可以从任何服务器连接
mysql> CREATE USER 'ucms'@'%' IDENTIFIED BY 'ucms';
授权,把ucms数据库是所以权限授权给ucms用户
mysql> GRANT ALL PRIVILEGES ON ucms.* TO 'ucms'@'%' IDENTIFIED BY 'ucms' WITH GRANT OPTION;
刷新权限,使之生效
mysql> FLUSH PRIVILEGES ;
linux安装mysql-5.1.60 tar.gz