采用二进制包安装MysqL
二进制软件包名称
MysqL-5.5.49-linux2.6-x8.6_64.tar.gz
添加用户,但这个用户不能登陆)
groupadd MysqL
useradd -s /sbin/nologin -g MysqL -M MysqL
tail -1 /etc/passwd
id MysqL
root@ubuntu:/usr/local# cd /usr/local # 切换到要安装的目录
root@ubuntu:/usr/local# wget http://dev.MysqL.com/get/Downloads/MysqL-5.5/MysqL-5.5.49-linux2.6-x86_64.tar.gz
root@ubuntu:/usr/local# mkdir -p /application/
root@ubuntu:/usr/local# mv MysqL-5.5.49-linux2.6-x86_64 /application/MysqL-5.5.49
root@ubuntu:/usr/local# ln -s /application/MysqL-5.5.49/ /application/MysqL
root@ubuntu:/usr/local# ls -l /application/MysqL
lrwxrwxrwx 1 root root 26 Oct 15 19:47 /application/MysqL -> /application/MysqL-5.5.49/
root@ubuntu:/usr/local# cd /application/MysqL/
root@ubuntu:/application/MysqL# ls -l support-files/*.cnf
-rw-r--r-- 1 7161 uucp 4691 Mar 1 2016 support-files/my-huge.cnf
-rw-r--r-- 1 7161 uucp 19759 Mar 1 2016 support-files/my-innodb-heavy-4G.cnf
-rw-r--r-- 1 7161 uucp 4665 Mar 1 2016 support-files/my-large.cnf
-rw-r--r-- 1 7161 uucp 4676 Mar 1 2016 support-files/my-medium.cnf
-rw-r--r-- 1 7161 uucp 2840 Mar 1 2016 support-files/my-small.cnf
root@ubuntu:/application/MysqL# /bin/cp support-files/my-small.cnf /etc/my.cnf
root@ubuntu:/application/MysqL# mkdir -p /application/MysqL/data
root@ubuntu:/application/MysqL# chown -R MysqL.MysqL /application/MysqL/
初始化数据库
root@ubuntu:/application/MysqL# /application/MysqL/scripts/MysqL_install_db --basedir=/application/MysqL --datadir=/application/MysqL/data --user=MysqL
Installing MysqL system tables...
171015 19:55:40 [Note] /application/MysqL/bin/MysqLd (MysqLd 5.5.49) starting as process 5924 ...
OK
Filling help tables...
171015 19:55:42 [Note] /application/MysqL/bin/MysqLd (MysqLd 5.5.49) starting as process 5930 ...
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 ubuntu 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 at http://bugs.MysqL.com/
root@ubuntu:/application/MysqL#
root@ubuntu:/application/MysqL# cp support-files/MysqL.server /etc/init.d/MysqLd
root@ubuntu:/application/MysqL# chmod +x /etc/init.d/MysqLd
root@ubuntu:/application/MysqL# ll /etc/init.d/MysqLd
-rwxr-xr-x 1 root root 10880 Oct 15 19:56 /etc/init.d/MysqLd*
root@ubuntu:/application/MysqL#
二进制默认路径为/usr/local/MysqL 启动脚本里面的路径要更改
root@ubuntu:/application/MysqL# sed -i 's#/usr/local/MysqL#/application/MysqL#g' /application/MysqL/bin/MysqLd_safe /etc/init.d/MysqLd
[root@template MysqL]# /etc/init.d/MysqLd start
Starting MysqL.. SUCCESS!
[root@template MysqL]# netstat -lntup|grep MysqL
tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 2224/MysqLd
设置MysqL 开机自启动
[root@template MysqL]# chkconfig --add MysqLd
[root@template MysqL]# chkconfig MysqLd on
[root@template MysqL]# chkconfig --list MysqLd
MysqLd 0:off 1:off 2:on 3:on 4:on 5:on 6:off
配置开机自启动
echo "#MysqL start by huzhihua at 2016-10-27" >>/etc/rc.local
echo "/etc/init.d/MysqLd start" >>/etc/rc.local
[root@template MysqL]# tail -2 /etc/rc.local
#MysqL start by huzhihua at 2016-10-27
/etc/init.d/MysqLd start
配置MysqL命令的全局使用路径
[root@template MysqL]# echo 'export PATH=/application/MysqL/bin:$PATH' >>/etc/profile
[root@template MysqL]# tail -1 /etc/profile
export PATH=/application/MysqL/bin:$PATH
[root@template MysqL]# source /etc/profile
[root@template MysqL]# echo $PATH
/application/MysqL/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin
别外三种登录方法:
MysqL -uroot -p,MysqL -uroot
MysqL -uroot -p 'oldboy123'
[root@template MysqL]# MysqL
Welcome to the MysqL monitor. Commands end with ; or \g.
Your MysqL connection id is 1
Server version: 5.5.49 MysqL Community Server (GPL)
Copyright (c) 2000, 2016, 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 #退出
请退出MysqL,再设置密码
MysqLadmin -u root password '123456'
2、采用yum的方式安装MysqL
安装:
服务端启动
MysqL.server star
Ubuntu安装方法
sudo apt-get update
sudo apt-get install MysqL-server -y
sudo apt-get install MysqL-client -y
sudo service MysqL restart
@H_403_136@
参考文章:http://www.cnblogs.com/nulige/p/6020435.html
@H_403_136@
总结
如果觉得编程之家网站内容还不错,欢迎将编程之家网站推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您喜欢交流学习经验,点击链接加入交流1群:1065694478(已满)交流2群:163560250