mysql 安装


1、安装方法mysql安装常见的方法有四种
2、安装步骤创建mysql 用户groupadd mysqluseradd -s /sbin/nologin -g mysql -M mysql (不创建家目录)
获取软件包可以选择国内的sohu镜像站点下载http://mirrors.sohu.com/mysql/可以选择自己要使用的其他版本http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.55-linux2.6-x86_64.tar.gz

二进制安装[root@bj-web-001 opt]# cd /opt/[root@bj-web-001 opt]#wget http://mirrors.sohu.com/mysql/MySQL-5.5/mysql-5.5.55-linux2.6-x86_64.tar.gz[root@bj-web-001 opt]# tar xf mysql-5.5.55-linux2.6-x86_64.tar.gz[root@bj-web-001 opt]# ln -s mysql-5.5.55-linux2.6-x86_64 mysql[root@bj-web-001 opt]# ls -l mysqllrwxrwxrwx 1 root root 28 6月 27 22:13 mysql -> mysql-5.5.55-linux2.6-x86_64[root@bj-web-001 mysql]# ls -l support-files/*.cnf-rw-r–r– 1 7161 31415 4691 3月 18 13:14 support-files/my-huge.cnf-rw-r–r– 1 7161 31415 19759 3月 18 13:14 support-files/my-innodb-heav开发云主机域名y-4G.cnf-rw-r–r– 1 7161 31415 4665 3月 18 13:14 support-files/my-large.cnf-rw-r–r– 1 7161 31415 4676 3月 18 13:14 support-files/my-medium.cnf-rw-r–r– 1 7161 31415 2840 3月 18 13:14 support-files/my-small.cnf[root@bj-web-001 mysql]# /bin/cp support-files/my-small.cnf /etc/my.cnf[root@bj-web-001 ~]# chown -R mysql.mysql /opt/mysql/[root@bj-web-001 ~]# ll /opt/mysql/ 总用量 72drwxr-xr-x 2 mysql mysql 4096 6月 27 22:08 bin-rw-r–r– 1 mysql mysql 17987 3月 18 12:41 COPYINGdrwxr-xr-x 3 mysql mysql 4096 6月 27 22:08 datadrwxr-xr-x 2 mysql mysql 4096 6月 27 22:08 docsdrwxr-xr-x 3 mysql mysql 4096 6月 27 22:08 include-rw-r–r– 1 mysql mysql 301 3月 18 12:41 INSTALL-BINARYdrwxr-xr-x 3 mysql mysql 4096 6月 27 22:09 libdrwxr-xr-x 4 mysql mysql 4096 6月 27 22:08 mandrwxr-xr-x 10 mysql mysql 4096 6月 27 22:09 mysql-test-rw-r–r– 1 mysql mysql 2496 3月 18 12:41 READMEdrwxr-xr-x 2 mysql mysql 4096 6月 27 22:08 scriptsdrwxr-xr-x 27 mysql mysql 4096 6月 27 22:09 sharedrwxr-xr-x 4 mysql mysql 4096 6月 27 22:08 sql-benchdrwxr-xr-x 2 mysql mysql 4096 6月 27 22:08 support-files[root@bj-web-001 ~]# /opt/mysql/scripts/mysql_install_db –basedir=/opt/mysql –datadir=/opt/mysql/data/ –user=mysql[root@bj-web-001 ~]# tree /opt/mysql/data//opt/mysql/data/├── mysql│ ├── columns_priv.frm│ ├── columns_priv.MYD│ ├── columns_priv.MYI│ ├── db.frm│ ├── db.MYD│ ├── db.MYI│ ├── event.frm│ ├── event.MYD│ ├── event.MYI│ ├── func.frm│ ├── func.MYD│ ├── func.MYI[root@bj-web-001 mysql]# cp support-files/mysql.server /etc/init.d/mysqld[root@bj-web-001 mysql]# chmod +x /etc/init.d/mysqld[root@bj-web-001 mysql]# sed -i ‘s#/usr/local/mysql#/opt/mysql#g’ /opt/mysql/bin/mysqld_safe /etc/init.d/mysqld[root@bj-web-001 mysql]# /etc/init.d/mysqld startStarting MySQL.Logging to ‘/opt/mysql/data/bj-web-001.err’.. SUCCESS!还可以使用 (2选1)[root@bj-web-001 mysql]# /opt/mysql/bin/mysqld_safe –user=mysql &[root@bj-web-001 mysql]# netstat -ntpl|grep mysqltcp 0 0 0.0.0.0:3306 0.0.0.0:* LISTEN 58844/mysqld 要是启动失败,需要查看日志[root@bj-web-001 mysql]# tail -f data/bj-web-001.errInnoDB: Creating foreign key constraint system tablesInnoDB: Foreign key constraint system tables created设置开机启动[root@bj-web-001 data]# chkconfig –add mysqld[root@bj-web-001 data]# chkconfig mysqld on[root@bj-web-001 data]# chkconfig –list mysqldmysqld 0:关闭 1:关闭 2:启用 3:启用 4:启用 5:启用 6:关闭配置环境变量[root@bj-web-001 data]# echo ‘export PATH=/opt/mysql/bin:$PATH’ >> /etc/profile[root@bj-web-001 data]# tail -1 /etc/profileexport PATH=/opt/mysql/bin:$PATH[root@bj-web-001 data]# source /etc/profile[root@bj-web-001 data]# echo $PATH/opt/mysql/bin:/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin:/root/bin测试登录[root@bj-web-001 data]# mysqlWelcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 1Server version: 5.5.55 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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> show databases;+——————–+| Database |+——————–+| information_schema || mysql || performance_schema || test |+——————–+4 rows in set (0.00 sec)
mysql> select user();+—————-+| user() |+—————-+| root@localhost |+—————-+1 row in set (0.00 sec)
mysql> qBye设置密码[root@bj-web-001 data]# mysqladmin -u root password ‘123456’[root@bj-web-001 data]# mysqlERROR 1045 (28000): Access denied for user ‘root’@’localhost’ (using password: NO)[root@bj-web-001 data]# mysql -u root -pEnter password:Welcome to the MySQL monitor. Commands end with ; or g.Your MySQL connection id is 4Server version: 5.5.55 MySQL Community Server (GPL)
Copyright (c) 2000, 2017, 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> DELETE FROM mysql.user WHERE user = ”; [删除匿名帐户]mysql> select user,host from mysql.user;+——+————+| user | host |+——+————+| root | 127.0.0.1 || root | ::1 || | bj-web-001 || root | bj-web-001 || | localhost || root | localhost |+——+————+6 rows in set (0.00 sec)
mysql> drop user “root”@”::1″;Query OK, 0 rows affected (0.00 sec)
mysql> drop user “”@”localhost”; Query OK, 0 rows affected (0.00 sec)
mysql> drop user “”@”bj-web-001”; Query OK, 0 rows affected (0.00 sec)
mysql> drop user “root”@”bj-web-001”;Query OK, 0 rows affected (0.00 sec)
mysql> select user,host from mysql.user;+——+———–+| user | host |+——+———–+| root | 127.0.0.1 || root | localhost |+——+———–+2 rows in set (0.00 sec)
mysql> flush privileges;Query OK, 0 rows affected (0.00 sec)删除无用数据mysql> drop database test;Query OK, 0 rows affected (0.00 sec)
mysql> show databases;+——————–+| Database |+——————–+| information_schema || mysql || performance_schema |+——————–+3 rows in set (0.00 sec)
mysql>
至此,二进制安装mysql数据库完成。

相关推荐: MySQL5.6.44 [Err] 1067 – Inval

场景[Err] 1067 – Invalid default value for ‘create_date’,对于创建表种的语句如下:`create_date`timestamp(0)NOTNULLONUPDATECURRENT_TIMESTAMP(0)COM…

免责声明:本站发布的图片视频文字,以转载和分享为主,文章观点不代表本站立场,本站不承担相关法律责任;如果涉及侵权请联系邮箱:360163164@qq.com举报,并提供相关证据,经查实将立刻删除涉嫌侵权内容。

(0)
打赏 微信扫一扫 微信扫一扫
上一篇 06/06 19:45
下一篇 06/06 19:45

相关推荐