I just installed mysql-server on Ubuntu22.04 using apt, it’s running as a service, everything appears to be fine. It was installed without a root pwd, and while trying to create one I run into a syntax error at the end of the process.
Initial newbie tries:
root@DEV: mysql -u root –skip-password (denied, nothing in error.log)
root@DEV: mysqladmin -u root -p password (denied, nothing in error.log)
Final try after further research:
- [root ~]# systemctl stop mysql
- In terminal A [root ~]# mysqld_safe –skip-grant-tables &
- In terminal B: mysql -u root (gets me in)
- mysql> use mysql;
- mysql> select * from user; (returns “empty set”)
- mysql> truncate table user; (returns “Query OK, zero rows affected”)
- mysql> flush privileges; (returns “Query OK”)
So, everything is good to this point but now commence the syntax errors. To wit:
- mysql> grant all privileges on . to root@localhost identified by ‘admin’ with grant option; (note the quotes around admin)
- mysql> grant all privileges on . to root@localhost identified by admin with grant option; (no quotes around admin)
- mysql> alter user root@localhost identified by admin;
(note syntax error says “near ‘admin'”) - mysql> alter user root@localhost identified by ‘admin’;
(note “ERROR 1396 (HY000): Operation ALTER USER failed for ‘root’@’localhost'”) - mysql> ALTER USER ‘root’@’%’IDENTIFIED BY ‘admin’;
(using quoted root ID, note syntax error “near ‘admin'”)
Thanks for your time and advice.