ubuntu mysql安装和修改密码

时间:2022-06-10 06:42:24

sudo apt-get install mysql-server

sudo apt-get install mysql-client

sudo apt-get install libmysqlclient-dev

文件:/etc/mysql/debian.cnf   记录创建数据库时初始账户,可用此登录

error: ‘Access denied for user ‘root‘@‘localhost‘ (using password: YES)‘解决办法:

/etc/init.d/mysql stop         #停止mysql   or service mysql stop

su root

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

#此步骤报错:mysqld_safe Directory ‘/var/run/mysqld’ for UNIX socket file don’t exists

mkdir -p /var/run/mysqld
chown mysql:mysql /var/run/mysqld

mysqld_safe --user=mysql --skip-grant-tables --skip-networking &

mysql -u root mysql    #进入mysql交互模式

update user set authentication_string=PASSWORD("your_psswrd") where user=root;   #mysql的密码都存储在mysql库的user表里,直接更新用户表
update user set plugin="mysql_native_password";

flush privileges;   #更新权限

quit;

mysql -u root -p  #重新登录

在apt安装软件时,出现了hash校验和不符的问题,热点网换成学校网好了,貌似是运营商问题?