mysql下载starting the servermysql1.6安装⽅法_mysql数据的安装说明:mysql的版本:mysql-5.5.21-linux2.6-x86_
1.添加傀儡⽤户
[root@web01 ~]# useradd -s /sbin/nologin -M mysql
[root@web01 ~]# id mysql
uid=502(mysql) gid=502(mysql) 组=502(mysql)
2.上传⼆进制包(⽬录没有⾃⼰创建,这是安装nginx的时候创建的⽬录,都放在⼀起)
[root@web01 ~]# cd /home/oldboy/tools/
[root@web01 tools]# ls
nginx-1.6.3 nginx-1.6.
[root@web01 tools]# rz
rz waiting to receive.
zmodem trl+C
100% 181708 KB 8652 KB/s 00:00:21 0 Errorss86_
[root@web01 tools]# ls
mysql-5.5.21-linux2.6-x86_ nginx-1.6.3 nginx-1.6.
[root@web01 tools]# ls
mysql-5.5.21-linux2.6-x86_ nginx-1.6.3 nginx-1.6.
3.解压⼆进制包
[root@web01 tools]# tar xf mysql-5.5.21-linux2.6-x86_
[root@web01 tools]# ls
mysql-5.5.21-linux2.6-x86_64 nginx-1.6.3
mysql-5.5.21-linux2.6-x86_ nginx-1.6.
4.⼆进制包不⽤编译,把解压的⼆进制包放在规定的位置,做做软连接,⽅便管理
[root@web01 tools]# mv mysql-5.5.21-linux2.6-x86_64 /application/mysql-5.5.32
[root@web01 tools]# ln -s /application/mysql-5.5.32 /application/mysql
[root@web01 tools]# ll /application/mysql
lrwxrwxrwx 1 root root 25 5⽉ 11 16:32 /application/mysql -> /application/mysql-5.5.32
5.初始化数据库(两个OK正确的标志)
--basedir=/application/mysql/ 指定安装的⽬录
datadir=/application/mysql/data/ 指定数据存放的位置
--user=mysql 指定⽤户
[root@web01 ~]# /application/mysql/scripts/mysql_install_db --basedir=/application/mysql/ --datadir=/application/mysql/data/ --user=mysql
Installing MySQL
OK
Filling
OK
To start mysqld at boot time you have to copy
support-files/mysql.server to the right place for your system
PLEASE REMEMBER TO SET A PASSWORD FOR THE MySQL root USER !
To do so, start the server, then issue the following commands:
/application/mysql//bin/mysqladmin -u root password 'new-password'
/application/mysql//bin/mysqladmin -u root -h web01 password 'new-password'
Alternatively you can run:
/application/mysql//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.
You can start the MySQL daemon with:
cd /application/mysql/ ; /application/mysql//bin/mysqld_safe &
You can test the MySQL daemon with mysql-test-run.pl
cd /application/mysql//mysql-test ; perl mysql-test-run.pl
Please report any problems with the /application/mysql//scripts/mysqlbug script!
6.授权mysql管理数据库⽂件
[root@web01 ~]# chown -sql /application/mysql/
7.⽣成mysql的配置⽂件
[root@web01 support-files]# pwd
/application/mysql/support-files
[root@web01 support-files]# cp my-smallf/etc/myf
cp:是否覆盖"/etc/myf"? y
[root@web01 support-files]#
8修改mysql启动的⽂件路径(默认是:/application/mysql/bin/mysqld_safe)
[root@web01 ~]# cat /application/mysql/bin/mysqld_safe
[root@web01 local]# sed -i 's#/usr/local/mysql#/application/mysql#g' /application/mysql/bin/mysqld_safe 9.后台启动mysql
[root@web01 local]# /application/mysql/bin/mysqld_safe &
[root@web01 local]# lsof -i:3306
COMMAND PID USER FD TYPE DEVICE SIZE/OFF NODE NAME
mysqld 1712 mysql 10u IPv4 10536 0t0 TCP *:mysql (LISTEN)
①把mysql的命令的路径加到PATH路径下(建议使⽤这⼀种)
[root@web01 ~]# PATH="/application/mysql/bin:$PATH"
②把mysql的命令拷贝到已知的PATH路径下(上课⽼师⽤的这⼀种,正确)
[root@web01 bin]# echo $PATH
/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
[root@web01 bin]# cp /application/mysql/bin/* /usr/local/sbin/
[root@web01 bin]# which mysql
/
usr/local/sbin/mysql
11.调整启动的⽅式
[root@web01~]#cp /application/mysql/support-files/mysql.server /etc/init.d/mysqld [root@web01 ~]# sed -i 's#/usr/local/mysql#/application/mysql#g' /etc/init.d/mysqld [root@web01 ~]# chmod +x /etc/init.d/mysqld
12.测试启动顺序的调整(⽣产环境不要⽤pkill)
[root@web01 ~]# killall mysqld
[root@web01 ~]# lsof -i:3306
[root@web01 ~]# /etc/init.d/mysqld start
Starting MySQL.. SUCCESS!
13.加⼊开机⾃启服务
[root@web01 ~]# chkconfig mysqld on
[root@web01 ~]# chkconfig --list mysqld
mysqld 0:off 1:off 2:on 3:on 4:on 5:on 6:off
14.修改mysql的密码(默认是没有密码的)
[root@web01 ~]# mysqladmin -uroot password "123456"
测试:
[root@web01 ~]# mysql -uroot -p123456
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 4
Server version: 5.5.21 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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>
[root@web01 ~]# mysqladmin -uroot -p123456 password "oldboy"
[root@web01 ~]# mysql -uroot -p123456
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) [root@web01 ~]# mysql -uroot -poldboy
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.21 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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>
16.交互式给密码(这样在history历史记录没有办法看到密码)
[root@web01 ~]# mysqladmin -uroot -p123456 password "oldboy"
[root@web01 ~]# mysql -uroot -p123456
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: YES) [root@web01 ~]# mysql -uroot -poldboy
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.5.21 MySQL Community Server (GPL)
Copyright (c) 2000, 2011, 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>
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系QQ:729038198,我们将在24小时内删除。
发表评论