Elijah Lofgren

I follow Jesus Christ and enjoy reading, writing, helping people, and making websites. Who is Jesus?

My life mission: "Whatever you do, do it all for the glory of God." - 1 Corinthians 10:31

You are here: Home » Web Dev Tips » MySQL Tips » How to quickly and easily add a new MySQL user and Database using the MySQL command line

How to quickly and easily add a new MySQL user and Database using the MySQL command line

From: gtd-php Documentation | Users / GTD-PHP Version 0.8 Installation Instructions:

# In mysql create a database; you can give it any name you like; we suggest calling it gtd; you will be prompted for the mysql root password.
    mysql -u root -p -e "create database gtd"
# Create a MySQL user for gtd-php to run under. Note that you should also set proper mysql permissions for the mysql user. This user should not have access to other databases, nor grant privileges; this user should not be the root user. Change and in the line below to something else, this is the username and password for the gtd database:
   mysql -u root -p -e "grant all privileges on dbname.* to username@localhost identified by 'theuserpassword'; flush privileges;"