Linux——MySQL 安装

系统 centOS6.5,yum 方式安装

MySQL 下载

  • yum install mysql-server,之后输入 y,确定安装

初始化 MySQL

  • 启动服务,service mysqld start

  • 查看端口号,netstat -tnlp,默认端口是3306

  • 进入初始化,mysql_secure_installation,命令很长,可以先输入 mysql_sec ,之后 tab 键盘就能看到提示

    • Enter current password for root(enter for none),输入当前 root 用户密码,第一次配置肯定没有,直接回车,这里 root 非linux下的管理员的登陆密码,而是数据库的密码
    • Set root password,是否设置密码,需要设置,输入 y
    • Remove anonymous users,是否移除匿名用户,输入 y
    • Disallow root login remotely,不允许 root 远程登陆,这里不管如何设置都不管用,输入n
    • Remove test database and access to it,是否移除测试数据库,输入n
    • Reload privilege tables now,是否重载权限表,以上因为做了修改,所以输入 y
    • 配置结束

进入 MySQL

  • mysql -u用户名 -p,不建议直接在p后面写入自己的密码,应该回车之后输入

  • 输入密码,进入 mysql 环境

MySQL 默认目录

  • 数据库存储目录,/var/lib/mysql

  • 配置文件目录,/etc/my.cnf

程序的启动与停止

  • service mysql start/stop/restart
posted @ 2018-07-07 12:19  cnloop  阅读(119)  评论(0编辑  收藏  举报