Fix: ERROR 1396 (HY000): Operation CREATE USER failed in MySQL? This is a mysql 8 bug. Suppose the user is myuser . 1. The user already exists. Delete them with DROP. (not DELETE). DROP USER myuser. DO NOT use "delete from mysql.user where user=myuser". 2. You already deleted them with DELETE. Try it again with DROP, even if they do not exist. If you are too late and you already made the mistake in (1) above you can either create a new user with a different name, e.g. myuser2, or, repeat the drop statement above in (1). 3. The password doesn't meet the default MySQL 8 requirements. Sometimes it is because the password isn't good enough. It must be 8 chars minimum, with at least one caps, one lower, one number, and one punctuation. 4. Check your mysql supports old passwords ( mysql_native_password). Use CREATE USER 'myuser'@'localhost' IDENTIFIED WITH mysql_native_password BY 's0m3Pa...
Sometimes you just want a specific mysql table. mysqldump -u [username] -p --no-create-info source_database_name source_table_name > saved_database_content.sql You can then load that content into a new database: mysql -u [username] -p target_database_name < saved_database_content.sql
Warning: this will delete ALL your databases. After running this script it will let you automatically run mysql without a password (as root). Note this is a security risk so do not run this on a production server. #!/bin/bash set -e # Function to remove MySQL and clean up remove_mysql() { echo "Removing MySQL server and packages..." sudo apt-get remove -y mysql-server mysql-client mysql-common echo "Removing MySQL directories..." sudo rm -rf /etc/mysql /var/lib/mysql /var/log/mysql /var/run/mysqld # Clean up any residual packages and update package info sudo apt-get autoremove -y sudo apt-get clean } # Function to ensure MySQL configuration file exists ensure_mysql_config() { if [ ! -f /etc/mysql/mysql.cnf ]; then echo "Creating MySQL configuration file..." echo "[client]" | sudo tee /etc/mysql/mysql.cnf ...
Comments
Post a Comment