20130819 mysql create db and user - plembo/onemoretech GitHub Wiki
title: mysql create db and user link: https://onemoretech.wordpress.com/2013/08/19/mysql-create-db-and-user/ author: phil2nc description: post_id: 6261 created: 2013/08/19 13:28:00 created_gmt: 2013/08/19 17:28:00 comment_status: closed post_name: mysql-create-db-and-user status: publish post_type: post
mysql create db and user
I get asked this a lot. Here's how to create a MySQL database and user from the command line. Log in as the root user (mysql -u root -p) and then issue the following command: [code language="sql" gutter="false"] mysql> create database owncloud; [/code] In this example the name of my db is "owncloud". To create a user who "owns" the database, use this syntax: [code language="sql" gutter="false"] mysql> grant all privleges on owncloud.* to 'owncloud'@'localhost' identified by 'mypassword'; [/code] Here we're granting all rights over all tables in the owncloud database (owncloud.*) to a user called owncloud. Notice that the user and host names are enclosed in single quotes, as is the user's password. Whenever creating users or altering privileges on a database be sure follow up with a "flush" command: [code language="sql" gutter="false"] mysql> flush privileges; [/code]
Copyright 2004-2019 Phil Lembo