mysql安装 + 链接qt

    技术2025-11-19  3

    #mysql安装 sudo apt-get install mysql-server sudo apt-get install mysql-client #qt连接mysql sudo apt-get install libmysqlclient-dev sudo apt-get install libqt5sql5-mysql 在ubuntu上有一些版本的mysql在安装时会弹出命令行界面让用户设置登录mysql的密码,也有一些系统版本的mysql不会弹出设置密码的界面,这些和镜像源有关系,不同镜像源下载的mysql版本不一样,比如在arm上,清华源下载的版本比较新,ustc源比较稳定 问题1: mysql -u root登录,报错: ERROR 1698 (28000): Access denied for user 'root'@'localhost' 解决方法: 可能出现无法以password登录mysql的问题,用ps aux|grep mysql查看进程未开启 sudo mysql -u root,成功登录 设置root密码 : mysql> set password for root@localhost = password('密码'); 为什么必须sudo才能登录? sudo登录进入mysql后,select user, plugin from mysql.user; 查看usr表:root的plugin是auth_socket ,用密码登陆的plugin应该是 mysql_native_password 需要修改类型: mysql> update mysql.user set authentication_string=PASSWORD('密码'), plugin='mysql_native_password' where user='root'; flush privileges 退出再登录即可不用sudo
    Processed: 0.010, SQL: 9