Linux centOS/ubuntu 安装mysql详细教程
发布时间:2020-12-12 02:25:11 所属栏目:MySql教程 来源:网络整理
导读:采用二进制包安装mysql 二进制软件包名称 mysql-5.5.49-linux2.6-x8.6_64.tar.gz 添加用户和组( ?添加用户,但这个用户不能登陆 ) groupadd?mysqluseradd?-s?/sbin/nologin?-g?mysql?-M?mysqltail?-1?/etc/passwdid?mysql 开始安装MySQL root@ubuntu:/usr/lo
采用二进制包安装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 开始安装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 启动mysql数据库 [root@template?mysql]#?/etc/init.d/mysqld?start Starting?MySQL..?SUCCESS! 检查mysql数据库是否启动 [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 别外三种登录方法: 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
安装: |