centos安装配置mysql数据库。

  1. 安装mysql

    yum install -y mysql-server mysql mysql-devel 
    
  2. 启动

    service mysqld start
    
  3. 设置开机启动

    chkconfig mysqld on
    
  4. 修改密码

    mysqladmin -u root password '111111'
    
  5. 登陆

    mysql -u root -p
    
  6. 创建数据库

    create database gophper;
    
  7. mysql登录报错“Access denied for user ‘root’@‘localhost’ (using password: YES”的处理方法

    # /etc/init.d/mysqld stop 
    # mysqld_safe --user=mysql --skip-grant-tables --skip-networking & 
    # mysql -u root mysql 
    mysql> UPDATE user SET Password=PASSWORD(’newpassword’) where USER=’root’; 
    mysql> FLUSH PRIVILEGES; 
    mysql> quit 
    # /etc/init.d/mysqld restart 
    # mysql -uroot -p 
    Enter password: <输入新设的密码newpassword> 
    mysql>