CodeGuru Forums - Database https://forums.codeguru.com/ Discuss databases, database technologies, and database programming. ADO.NET and XML questions and comments have a separate forum. en Wed, 21 Feb 2024 14:19:28 GMT vBulletin 60 https://forums.codeguru.com/images/misc/rss.png CodeGuru Forums - Database https://forums.codeguru.com/ <![CDATA[another Access denied for user 'root'@'localhost' (using password: NO)]]> https://forums.codeguru.com/showthread.php?566239-another-Access-denied-for-user-root-localhost-(using-password-NO)&goto=newpost Sun, 04 Feb 2024 22:45:31 GMT FLUSH PRIVILEGES; > USE mysql; syntex error with > ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root'; --------------- edit ---------- had issue with: $ sudo /usr/sbin/mysqld --user=root --skip-grant-tables --skip-networking & but got $ sudo mariadbd --user=root --skip-grant-tables --skip-networking to work $ sudo mysql > FLUSH PRIVILEGES; > USE mysql; > ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password USING 'root'; ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost' > ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password AS 'root'; ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost' > exit [note: maybe not using $ sudo mysql -u root, was an error] $ sudo mysql -u root ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) $ sudo mysql ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO) --------------- edit ---------- trying to use https://www.mysqltutorial.org/getting-started-with-mysql/install-mysql-ubuntu/, ALTER USER root@localhost aint working. trying to start server, complaints about files occur, delete the file, another complaint, give time, do something else, and it starts. using $ sudo mysql -u root does samething as $ sudo mysql --------------- edit ---------- MariaDB [mysql]> SELECT user, host, password, HEX(authentication_string) FROM mysql.user; +-------------+-----------+----------+----------------------------+ | User | Host | Password | HEX(authentication_string) | +-------------+-----------+----------+----------------------------+ | mariadb.sys | localhost | | | | root | localhost | invalid | 696E76616C6964 | | mysql | localhost | invalid | 696E76616C6964 | +-------------+-----------+----------+----------------------------+ 3 rows in set (0.001 sec) I find a lot that is suppose to work, be either I am doing something wrong, or the very common error ... --------------- edit ---------- lol, i really did not expect it to sort of work: MariaDB [mysql]> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password USING 'invalid'; Query OK, 0 rows affected (0.018 sec) i thought to goal was to change password. --------------- edit ---------- well, I got the password removed, but can not change password. MariaDB [mysql]> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password USING ''; Query OK, 0 rows affected (0.012 sec) .]]> in one terminal:
sudo mariadbd --user=root --feedback=ON

in another terminal:
sudo mariadb
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

several threads about Access denied for user 'root'@'localhost' , said --user=root, would fix error.
maybe there is info that was not included, that is assumed everyone knows.

mysql server is running, sudo find / -type s , shows mysql is running

i have even uninstalled and reinstalled.

found some that said use:
ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

but seems to only be recognized, but not change error, with mysql client, but can not get mariadb client to start.

Access denied for user 'root'@'localhost' , occurs from more than one place.

--------------- edit ----------
tried:
sudo mysqlcheck --auto-repair --all-databases -p
got
mysqlcheck: Got error: 1045: Access denied for user 'root'@'localhost' (using password: YES) when trying to connect

--------------- edit ----------
tried:
sudo mysql -u root mysql
got
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

--------------- edit ----------
tried:
sudo mysqlcheck --auto-repair --all-databases
got
mysqlcheck: Got error: 1045: Access denied for user 'root'@'localhost' (using password: NO) when trying to connect

--------------- edit ----------
tried
mysql -uroot
got
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

--------------- edit ----------
i am guessing
update user set authentication_string=password('my_password') where user='root';
should be in mysql client, not on command line, because it gives
bash: syntax error near unexpected token `('

and gives:
ERROR 1356 (HY000): View 'mysql.user' references invalid table(s) or column(s) or function(s) or definer/invoker of view lack rights to use them
when in client

--------------- edit ----------
$ sudo systemctl stop mysql
$ sudo mkdir -p /var/run/mysqld
$ sudo chown mysql:mysql /var/run/mysqld
$ sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
[1] 3554
$ /usr/sbin/mysqld: Please consult the Knowledge Base to find out how to run mysqld as root!
2024-02-04 16:40:10 0 [ERROR] Aborting

[1]+ Exit 1 sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking

$ sudo /usr/sbin/mysqld --skip-grant-tables --skip-networking &
should be
$ sudo /usr/sbin/mysqld --user=root --skip-grant-tables --skip-networking &

well, at least the server starts

--------------- edit ----------
client started
mysql -u root
> FLUSH PRIVILEGES;
> USE mysql;

syntex error with
> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password BY 'root';

--------------- edit ----------

had issue with:
$ sudo /usr/sbin/mysqld --user=root --skip-grant-tables --skip-networking &
but got
$ sudo mariadbd --user=root --skip-grant-tables --skip-networking
to work

$ sudo mysql
> FLUSH PRIVILEGES;
> USE mysql;
> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password USING 'root';
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'
> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password AS 'root';
ERROR 1396 (HY000): Operation ALTER USER failed for 'root'@'localhost'
> exit

[note: maybe not using $ sudo mysql -u root, was an error]

$ sudo mysql -u root
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)
$ sudo mysql
ERROR 1045 (28000): Access denied for user 'root'@'localhost' (using password: NO)

--------------- edit ----------
trying to use https://www.mysqltutorial.org/gettin...-mysql-ubuntu/,
ALTER USER root@localhost aint working.
trying to start server, complaints about files occur, delete the file, another complaint, give time, do something else, and it starts.

using $ sudo mysql -u root does samething as $ sudo mysql

--------------- edit ----------
MariaDB [mysql]> SELECT user, host, password, HEX(authentication_string) FROM mysql.user;
+-------------+-----------+----------+----------------------------+
| User | Host | Password | HEX(authentication_string) |
+-------------+-----------+----------+----------------------------+
| mariadb.sys | localhost | | |
| root | localhost | invalid | 696E76616C6964 |
| mysql | localhost | invalid | 696E76616C6964 |
+-------------+-----------+----------+----------------------------+
3 rows in set (0.001 sec)


I find a lot that is suppose to work, be either I am doing something wrong, or the very common error ...

--------------- edit ----------
lol, i really did not expect it to sort of work:
MariaDB [mysql]> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password USING 'invalid';
Query OK, 0 rows affected (0.018 sec)

i thought to goal was to change password.

--------------- edit ----------
well, I got the password removed, but can not change password.
MariaDB [mysql]> ALTER USER 'root'@'localhost' IDENTIFIED WITH mysql_native_password USING '';
Query OK, 0 rows affected (0.012 sec)


. ]]>
Database micha_eleric https://forums.codeguru.com/showthread.php?566239-another-Access-denied-for-user-root-localhost-(using-password-NO)
trying to get Database Programming with C/C++, by Manoj Debnath July 11, 2016 https://forums.codeguru.com/showthread.php?566230-trying-to-get-Database-Programming-with-C-C-by-Manoj-Debnath-July-11-2016&goto=newpost Wed, 24 Jan 2024 21:17:07 GMT host results in Access to field 'host' results in a dereference of a null pointer. Code: --------- CBankTransaction::CBankTransaction(const std::string HOST, const std::string USER, const std::string PASSWORD, const std::string DATABASE) { db_conn = mysql_init(NULL); if(db_conn) { db_conn = mysql_real_connect(db_conn, HOST.c_str(), USER.c_str(), PASSWORD.c_str(), DATABASE.c_str(), 0, NULL, 0); std::cout << "1: if(!db_conn) \n"; } else { std::cout << "1: else \n"; std::cout <<"db_conn->host = " << db_conn->host << '\n'; } if(!db_conn) { std::cout << "2: if(!db_conn) \n"; std::cout <<"db_conn->host = " << db_conn->host << '\n'; } else { std::cout << "2: else \n"; std::cout <<"db_conn->host = " << db_conn->host << '\n'; } } --------- both: Code: --------- db_conn = mysql_init(NULL); if(!db_conn) --------- and Code: --------- db_conn = mysql_init(NULL); if(db_conn) --------- result in trying to access a null pointer. is mysql server suppose to be started from outside of program? is there suppose to be a folder made somewhere, before program is run? something i am missing that was stated on https://www.codeguru.com/database/database-programming-with-c-c/ ?]]> trying to get Database Programming with C/C++, by Manoj Debnath July 11, 2016, to work, but having issues with getting basic part to run. db_conn is not zero, and db_conn->host results in Access to field 'host' results in a dereference of a null pointer.

Code:

CBankTransaction::CBankTransaction(const std::string HOST, const std::string USER,
                                  const std::string PASSWORD,
                                  const std::string DATABASE)
{
    db_conn = mysql_init(NULL);
    if(db_conn)
    {
        db_conn = mysql_real_connect(db_conn, HOST.c_str(), USER.c_str(),
                                PASSWORD.c_str(), DATABASE.c_str(), 0, NULL, 0);
        std::cout << "1: if(!db_conn) \n";
    }
    else
    {
        std::cout << "1: else \n";
        std::cout <<"db_conn->host = " << db_conn->host << '\n';
    }

    if(!db_conn)
    {
        std::cout << "2: if(!db_conn) \n";
        std::cout <<"db_conn->host = " << db_conn->host << '\n';
    }
    else
    {
        std::cout << "2: else \n";
        std::cout <<"db_conn->host = " << db_conn->host << '\n';
    }

}

both:
Code:

db_conn = mysql_init(NULL);
    if(!db_conn)

and

Code:

db_conn = mysql_init(NULL);
    if(db_conn)

result in trying to access a null pointer.
is mysql server suppose to be started from outside of program?
is there suppose to be a folder made somewhere, before program is run?
something i am missing that was stated on https://www.codeguru.com/database/da...ming-with-c-c/ ? ]]>
Database micha_eleric https://forums.codeguru.com/showthread.php?566230-trying-to-get-Database-Programming-with-C-C-by-Manoj-Debnath-July-11-2016