您的位置:首页 > 数据库 > MySQL

Ubuntu安装mysql

2016-07-26 10:16 423 查看
1、cd
/home
2、wget
http:
//oss.aliyuncs.com/aliyunecs/onekey/mysql/mysql-5.5.35-linux2.6-x86_64.tar.gz
3、tar
zxvf mysql-
5.5
.
35
-linux2.
6
-x86_64.tar.gz
[/code]
4、mv
mysql-5.5.35-linux2.6-x86_64 mysql
5、groupadd
mysql
6、useradd
-g mysql -s /sbin/nologin mysql
7、/home/mysql/scripts/mysql_install_db
--datadir=/home/mysql/data/ --basedir=/home/mysql --user=mysql
8、chown
-R mysql:mysql /home/mysql/
9、chown
-R mysql:mysql /home/mysql/data/
10、chown
-R mysql:mysql /home/log/mysql
11、\cp
-f /home/mysql/support-files/mysql.server /etc/init.d/mysql
12、sed
-i 's#^basedir=$#basedir=/home/mysql#' /etc/init.d/mysql
13、sed
-i 's#^datadir=$#datadir=/home/mysql/data#' /etc/init.d/mysql
14、\cp
-f /home/mysql/support-files/my-huge.cnf /etc/my.cnf
15、sed
-i 's#skip-locking#skip-external-locking\nlog-error=/home/log/mysql/error.log#' /etc/my.cnf
16、chmod
755 /etc/init.d/mysql
致此mysql安装完成,期间碰到目录不存在的则自行创建目录。
尝试下mysql是否能正常启动和停止:
root@iZ23k28j4i8Z:/home/mysql#
service mysql start

Starting MySQL

.. *
root@iZ23k28j4i8Z:/home/mysql#
netstat -tnl|grep 3306tcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN
root@iZ23k28j4i8Z:/home/mysql#
service mysql stopShutting down MySQL. *
看到了吧,mysql可以正常启动和停止了。
不过还没结束哦
增加链接:
ln
-s /home/mysql/bin/mysql /usr/binln -s /home/mysql/bin/mysqladmin /usr/bin
为root用户设置密码:
/home/mysql/bin/mysqladmin
-u root password '******'
用root登录mysql:
root@iZ23k28j4i8Z:/home/mysql#
mysql -uroot -p******Welcome to the MySQL monitor. Commands end with ; or \g.Your MySQL connection id is 2Server version: 5.5.35-log 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 itsaffiliates. Other names may be trademarks of their respectiveowners.Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.mysql>
登录mysql后执行以下三条命令:
mysql> GRANT
ALL PRIVILEGES ON *.* TO root
mysql> GRANT
ALL PRIVILEGES ON *.* TO root@localhost IDENTIFIED BY "密码"
mysql> GRANT
ALL PRIVILEGES ON *.* TO root IDENTIFIED BY "密码"
这样就可以用客户端工具以root及密码登录了。
如果有乱码则可以尝试以下解决方式:
修改/etc/my.cnf
[mysqld]在这里添加以下3行
character-set-server=utf8collation-server = utf8_unicode_ciinit_connect = 'set collation_connection = utf8_unicode_ci;'
内容来自用户分享和网络整理,不保证内容的准确性,如有侵权内容,可联系管理员处理 点击这里给我发消息
标签:  mysql ubuntu