1.解压mysql-standard-5.0.51-linux-i686-glibc23.tar.gz包。
tar -xzf mysql-standard-5.0.51-linux-i686-glibc23.tar.gz
2.更改mysql-standard-5.0.51-linux-i686-glibc23为mysql5
mv mysql-standard-5.0.51-linux-i686-glibc23 mysql5
3.修改mysql5的组别和用户为mysql
chown -R mysql.mysql mysql5
4.执行安装命令 指定用户为:mysql 指定安装路径为:/data1/mysql5/data
cd /data1/mysql5
/data1/mysql5/scripts/mysql_install_db --user=mysql --datadir=/data1/mysql5/data
5.复制启动脚本到data目录下
将mysql.sh 复制到data目录下 cp命令
6.确保使用mysql的用户为:mysql
7.登陆指定路径的mysql
mysql -uroot -p --socket=/data1/mysql5/data/mysql.sock -A
8.修改mysql状态下的root密码
1.mysql> use mysql;
2.mysql> update user set password=password('新密码') where user='root';
另外的方法:
1.mysql> set password for root@localhost=password('test');
2.shell>mysqladmin -uroot password test
9.新建mysql用户 例如新建test1的用户 密码为abc 可以在任何地方登陆mysql 访问所有数据库 且有查询,新建,修改,删除的权限。
grant select,insert,update,delete on *.* to test1@"%" Identified by "abc";
grant select,insert,update,delete on mydb.* to test1@"localhost" Identified by "abc"; 只能在本地登录 且只能访问mydb数据库
grant all privileges on *.* to test3@"%" identified by 'password' with grant option; 增加可以在任何地方访问数据库的超级用户
grant select on web_sg_en.* to websg@"%" Identified by "websg100919";
grant select on web_sg_en.* to websg@"localhost" Identified by "websg100919";
grant select,insert,create,update,delete,drop on web_sg_en.* to websg@"%" Identified by "websg100919";
grant select,insert,create,update,delete,drop on web_sg_en.* to websg@"localhost" Identified by "websg100919";
grant all privileges on web_sg_en.* to websg@"%" identified by 'websg100919' with grant option;
10.新建数据库 并赋予该数据库某个用户具有完全访问的权限
create database newdata;
grant all privileges on newdata.* to jcui@localhost identified by 'cui@6522123' with grant option;
grant all privileges on *.* to test@localhost identified by 'test' with grant option;
这句增加一个本地具有所有权限的test用户(超级用户),密码是test。ON子句中的*.*意味着"所有数据库、所有表"。with grant option表示它具有grant权限。
权限如下:
select
insert
update
delete
create
drop
11.数据库刷新命令
flush privileges;
12.删除新数据库中的空用户
mysql> delete from user where user='';
13.显示表的结构
describe sales_rep; 显示sales_rep表的结构
++++++++++++++++++++++++++++++++++++++++++++++++++
mysql启动脚本:
启动脚本:
#!/bin/sh
#
case $1 in
start)
cd /data1/mysql5
/data1/mysql5/bin/mysqld_safe --user=mysql --pid-file=/data1/mysql5/data/mysql.pid --log-error=/data1/mysql5/data/mysql.log --basedir=/data1/mysql5/ --
datadir=/data1/mysql5/data/ -O max_connections=500 -O log-slow-queries=/data1/mysql5/data/slow-queries.log -O long_query_time=1 --port=3306 --
socket=/data1/mysql5/data/mysql.sock &
;;
stop)
/data1/mysql5/bin/mysqladmin -uroot -ptest -S /data1/mysql5/data/mysql.sock shutdown
;;
status)
if [ -f /data1/mysql5/data/mysql.pid ] ; then
echo "mysqld process(`cat /data1/mysql5/data/mysql.pid`)running..."
else
echo "mysqld stoped."
fi
;;
*)
echo "Usage: /data1/mysql5/data/mysql_jcui.sh start|stop|status"
;;
esac