Beginners MySQL Doubts - mysql

I've started learning PHP with MySQL and come across some preliminary doubts. Hope someone helps clarify them..
I've come to know that there is a default user account named 'root' with no password. I changed the default password. Now, using command prompt when I try to login to mysql using C:\xampp\mysql\bin\mysql it returns me with the default MariaDB[(none)] prompt, but won't let me create any database, unless I login using actual password I set as: C:\xampp\mysql\bin\mysql -u root -p after which it prompts me to enter my password.
Also, it doesn't display the databases I created from within the root user account when I use the command show databases;
Is there a way to enter the required password from within the MariaDB[(none)] prompt mode? or do I have to manually exit and re-enter using mysql -u root -p ?
Should I have separate user account per project?
How is phpMyAdmin related with this user account, because it never asked my password?
Thanks in advance. Will come up with more doubts as I go on.

Related

how can I delete mysql with the root?

I forgot my mysql root password and tried everything I found on the internet to recover the password and nothing worked. I don't have any important databases. I want to remove it completely and reinstall it fresh so I can create a new root password.
Is it possible and how?
macOS
1. First, connect to the MySQL database as the root user:
mysql -u root -p
If root does not have access to MySQL on your machine, you can use sudo mysql
2. Enter the password when prompted and hit Enter. A MySQL shell loads.
3. Find the exact name of the user you want to remove by running a command that lists users from the MySQL server:
SELECT User, Host FROM mysql.user;
4. The output displays all users. Locate the name you want to remove, in our case it is MySQLtest. Replace username in the following command with your user:
DROP USER 'username'#'host';

WampServer mySQL

I have a mySQL database problem - I'm a newbie to this:
I've installed WAMP Server and I'm able to log into localhost then phpmyadmin to give the screen below (right image). But I get No xNo Privileges in red -- I see from online examples that I should see "Create new database":
Suggestions are welcome.
[I have no password and the login is just 'local']
You are getting this message because you have made up a userid and password.
MySQL's initial installation state has ONE userid defined called root.
This is the case regardless of how you installed MySQL, unless the install asks you for a password at installation time.
That is the SUPER USER and can do anything.
By default (again which ever way you install MySQL) this root user has no password.
So login to phpMyAdmin using :-
username = root
password = (leave this blank, empty)
Press the Login button.
You will now be loged in as root.
PS.
Its a good idea to add a password to this username, BUT PLEASE DONT FORGET IT, as recovery can be a pain.

How do I change the default password of MySQL root user on Cloudbees?

We are running Jenkins on Cloudbees for building our code base from Github repo for MifosX. For our Integration Test job, we need to create a MySQL DB before each run. We have been able to do that, but would like to change the default MySQL credentials which are "root" and blank password, to some specific "password". Can someone guide us on how to do that?
I assume you are following this guide.
If that's the case, you should be able to follow standard MySQL instructions for setting the root users' password:
mysqladmin -u root password NEWPASSWORD
But I'm not sure why you would want to secure this with a password. Any network ports are isolated from other users, and they certainly don't have access to your files.

How to Set Default Access for MySQL

I'm sure this is an easy question, but I can't seem to find the answer anywhere.
When I log into the command line mysql program, I want to have root access by just typing mysql. However, I need to type mysql -uroot -p, and then enter my password. How can I change this?
Thanks,
Adam
Here is a tutorial on getting MySql to log you in automatically.
Just follow the steps and you should be able to login to MySql by simply typing mysql, as shown in the following image:
When you first install mysql, the furst thing you should do is give root#localhost a password. To set the password to mys3cr3t, run the following:
UPDATE mysql.user SET password=password('mys3cr3t')
WHERE host='localhost' and user='root';
FLUSH PRIVILEGES;
EXIT
Now, you have to login with mysql -uroot -p
Next, you need to cleanup all security hazards. There is a script called mysql_secure_installation. Run it ASAP. Here is what is does: https://dba.stackexchange.com/a/13350/877
If you do not, there is a possibility of a Disk Level database attack : https://dba.stackexchange.com/a/13363/877
To test to see whether you have proper user authentication, run this:
SELECT USER(),CURRENT_USER();
What does this query tell you ???
USER() reports how you attempted to authenticate in MySQL
CURRENT_USER() reports how you were allowed to authenticate in MySQL
If CURRENT_USER() reports any anonymous users, go run mysql_secure_installation now !!!

Logging in as a different user on MySQL

I created a different user, when I try to log into mysql it will not let me. I think I am missing a step. I am using windows 7. When I log in it automatically asks me for a password. If I enter the root password I can use mysql. If I enter the password I have created for the user, I get an error I cannot read and the program exits. Do I need to first login as root then somehow log in as new user. I am very confused. The code I used to create the new user is here:
Trouble logging into mysql as non root
Try this:
>> mysql -u USERNAME -p
Press enter, and you'll be prompted for the password for USERNAME.
There is no mysql equivalent to Oracle's 'connect' statement in the sense that allows to switch a user once already logged in to a mysql console session.
You may have created the new user, but not given that user sufficient permissions on the database you're trying to manage.