Creating a MySQL table for use with Dynamic Routes: Difference between revisions
Jump to navigation
Jump to search
(Created page with "1. Connect to the mysql server (can be done on command line, through a GUI tool e.g. phpMyAdmin). The example is from the command line: <pre>mysql -u root -p</pre> 2. Define...") |
No edit summary |
||
(One intermediate revision by the same user not shown) | |||
Line 9: | Line 9: | ||
3. Change current session to use database: | 3. Change current session to use database: | ||
<pre>use | <pre>use customer</pre> | ||
4. Create table | 4. Create table | ||
Line 31: | Line 31: | ||
At the mysql prompt enter: | At the mysql prompt enter: | ||
<pre>use | <pre>use customer; | ||
INSERT INTO customer_priority (callerid,priority) VALUES ('12345678','normal'); | INSERT INTO customer_priority (callerid,priority) VALUES ('12345678','normal'); | ||
INSERT INTO customer_priority (callerid,priority) VALUES ('23456789','normal'); | INSERT INTO customer_priority (callerid,priority) VALUES ('23456789','normal'); | ||
Line 42: | Line 42: | ||
At the mysql prompt enter: | At the mysql prompt enter: | ||
<pre>use | <pre>use customer; | ||
select * from customers;</pre> | select * from customers;</pre> | ||
If all is well you should see the data that you inserted. | If all is well you should see the data that you inserted. |
Latest revision as of 11:22, 13 June 2016
1. Connect to the mysql server (can be done on command line, through a GUI tool e.g. phpMyAdmin). The example is from the command line:
mysql -u root -p
2. Define a new database:
create database `customer`;
3. Change current session to use database:
use customer
4. Create table
CREATE TABLE `customer_priority` ( `callerid` VARCHAR(20) NOT NULL , `priority` VARCHAR(10) NOT NULL , PRIMARY KEY (`callerid`(20)));
5. Setup mysql user to access the database.
The command assumes the database is on the same server as FreePBX. In the following example substitute dr_user and xxxxxxxx by your chosen username and password:
grant select on customer.customer_priority to dr_user@localhost identified by 'xxxxxxxx'; flush privileges;
6. Populate some test data, for example:
mysql -u root -p
At the mysql prompt enter:
use customer; INSERT INTO customer_priority (callerid,priority) VALUES ('12345678','normal'); INSERT INTO customer_priority (callerid,priority) VALUES ('23456789','normal'); INSERT INTO customer_priority (callerid,priority) VALUES ('34567890','top');
7. Before moving on to configure FreePBX, check that the user can access the table:
mysql -u calleriduser -p
At the mysql prompt enter:
use customer; select * from customers;
If all is well you should see the data that you inserted.